Overview
The WSO2 Identity Server Nuxt SDK (@asgardeo/nuxt) is a Nuxt module that adds authentication, user self-care, and organization management to Nuxt applications. It runs the OAuth 2.0 authorization code flow on the server, keeps the session in a signed, HTTP-only cookie, and gives your pages ready-made components and composables.
When you add the module to nuxt.config.ts, it:
- Registers server API routes under
/api/auth/*that handle sign-in, the OAuth callback, sign-out, tokens, the user profile, organizations, and branding. - Resolves the session and prefetches the user, profile, organizations, and branding on every server-rendered page request, then hydrates that state on the client.
- Auto-registers
<AsgardeoRoot>and the UI components with anAsgardeoprefix, such as<AsgardeoSignedIn>and<AsgardeoSignInButton>. - Auto-imports composables such as
useAsgardeo(),useUser(), anduseOrganization(). - Registers a named route middleware,
auth, that protects pages.
Installation¶
Use one of the following options to install the WSO2 Identity Server Nuxt SDK.
Then add the module to nuxt.config.ts:
Getting started¶
Try out the WSO2 Identity Server Nuxt quickstart guide.
Configuration¶
- Module configuration – The
asgardeooptions innuxt.config.tsand the environment variables the module reads.
Root component¶
<AsgardeoRoot>– Wraps your app inapp.vueand supplies the user, organization, theme, branding, flow, and i18n contexts that the components and composables read.
Components¶
All components are auto-registered. Use them in any <template> without importing them.
Action components¶
<AsgardeoSignInButton>– Starts the sign-in flow.<AsgardeoSignOutButton>– Signs the user out.<AsgardeoSignUpButton>– Starts the sign-up flow.
Control components¶
<AsgardeoSignedIn>– Renders content only when the user is signed in.<AsgardeoSignedOut>– Renders content only when the user is signed out.<AsgardeoLoading>– Renders content while the authentication state is loading.
Authentication components¶
<AsgardeoSignIn>– An embedded, app-native sign-in form.<AsgardeoSignUp>– An embedded, app-native sign-up form.<AsgardeoCallback>– A headless component that forwards OAuth callback parameters to the originating route.
User self-care components¶
<AsgardeoUser>– Exposes the signed-in user through a scoped slot.<AsgardeoUserProfile>– Displays and edits the user's profile.<AsgardeoUserDropdown>– A dropdown menu with user details, a profile view, and sign-out.
Organization components (B2B)¶
<AsgardeoOrganization>– Exposes the current organization through a scoped slot.<AsgardeoOrganizationProfile>– Displays the current organization's details.<AsgardeoOrganizationSwitcher>– Lets the user switch between organizations.<AsgardeoOrganizationList>– Lists the user's organizations.<AsgardeoCreateOrganization>– A form that creates a sub-organization.
Composables¶
All composables are auto-imported.
useAsgardeo()– Authentication state and the sign-in, sign-out, sign-up, and access token methods.useUser()– The user's SCIM2 profile and methods to update and refresh it.useOrganization()– The current organization, the user's organizations, and organization switching.useTheme()– The resolved theme and color scheme.useBranding()– The organization's branding preference.useAsgardeoI18n()– Translations and the current language of the SDK's UI.useFlow()– UI state of the embedded authentication flows.useFlowMeta()– Flow metadata used by the embedded authentication flows.
Route protection¶
authmiddleware – A named route middleware that redirects signed-out visitors to sign-in.defineAsgardeoMiddleware()– Creates a route middleware with a custom redirect and extra checks.
Server¶
- Server API routes – The
/api/auth/*routes that the module registers. - Server utilities – Helpers from
@asgardeo/nuxt/serverfor your own server routes, such asrequireServerSession()andgetValidAccessToken().
Guides¶
- Protecting routes – Protect pages and server routes.
- Accessing protected APIs – Call APIs with the user's access token.