Skip to main content

Nuxt SDK

The ThunderID Nuxt SDK (@thunderid/nuxt) is a Nuxt module that integrates ThunderID authentication into Nuxt 3 applications. It provides composables, auto-registered components, route middleware, server utilities, and a set of built-in API routes — all with full SSR hydration support.

Installation

Install the ThunderID Nuxt SDK using your preferred package manager:

npm install @thunderid/nuxt

Getting Started

Register the module and provide your application credentials in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
modules: ['@thunderid/nuxt'],
thunderid: {
clientId: '<your-client-id>',
clientSecret: '<your-client-secret>',
baseUrl: 'https://localhost:8090',
},
})

Then wrap your root layout with <ThunderIDRoot />:

app.vue
<template>
<ThunderIDRoot>
<NuxtPage />
</ThunderIDRoot>
</template>

For full setup instructions, see the Nuxt quickstart guide.

Features

Configuration

The SDK is configured via the thunderid key in nuxt.config.ts.

Composables

Auto-imported composables available in every component and page without explicit imports.

  • useThunderID() — Access auth state and trigger sign-in, sign-out, and sign-up flows
  • useUser() — Access the authenticated user object

Components

All components are auto-registered with the ThunderID prefix and do not require explicit imports.

Provider

  • <ThunderIDRoot /> — Root provider that mounts all authentication context providers

Control Components

Action Components

User Self-care Components

Middleware

  • defineThunderIDMiddleware() — Factory for creating route middleware that gates pages by auth state, organization, or required scopes
  • Named 'auth' middleware — pre-built middleware that redirects unauthenticated users to sign-in

Server Utilities

Server-only utilities imported from @thunderid/nuxt/server for use in API routes, server routes, and server middleware.

Utilities

Error Handling

  • ThunderIDError — Structured error class thrown by the SDK with typed ErrorCode values

Built-in API Routes

The module automatically registers the following server routes under /api/auth:

RouteMethodDescription
/api/auth/signinGETStart redirect-based sign-in
/api/auth/signinPOSTHandle embedded sign-in step
/api/auth/signupPOSTHandle embedded sign-up step
/api/auth/callbackGET / POSTOAuth callback handler
/api/auth/signoutPOSTSign out and return redirect URL
/api/auth/sessionGETGet current auth state
/api/auth/tokenGETGet client-safe access token
/api/auth/userGETGet user object
/api/auth/user/profileGET / PATCHGet or update SCIM2 user profile
/api/auth/brandingGETGet tenant branding preference

Package Exports

Export PathContents
@thunderid/nuxtModule, composables, components, middleware, types
@thunderid/nuxt/serveruseServerSession, requireServerSession, getValidAccessToken, getThunderIDContext
@thunderid/nuxt/utilscreateRouteMatcher
@thunderid/nuxt/errorsThunderIDError, ErrorCode
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy