Nuxt SDK
Nitro middleware and composables for Nuxt applications.
The Nuxt SDK (@zitadel/sdk-nuxt) is a Nuxt module. It registers Nitro server middleware and plugins, so Nuxt pages can read Zitadel auth state.
Generated setup
The CLI edits the first matching nuxt.config.{ts,mts,js,mjs} and writes the backend URL and the project ID to .env.local. The module keeps the URL on the server and gives the browser only the project ID and the proxy path.
Prerequisites
- Node.js 24 or newer. Run
node --versionto check. - Nuxt 4 or newer.
- A Zitadel project from
zitadel setup. Start the local runtime withnpx @zitadel/cli@latest start, then runnpx @zitadel/cli@latest setup --server localin your app's directory. See the Quickstart, or Add Zitadel to an existing app. - The URL, project ID and project secret. Setup writes them to
.env.localasZITADEL_URL,ZITADEL_PROJECT_ID,ZITADEL_PROJECT_SECRETandNUXT_PUBLIC_ZITADEL_PROJECT_ID.
Install the SDK
Setup installs the SDK. To add it yourself, run:
pnpm add @zitadel/sdk-nuxt@latestWire the SDK into your app
The CLI adds pages, module config, environment files, and the SDK package, and nothing else: the SDK loads the web components and exposes the auth state itself. On the Nuxt 4 layout, pages go under app/.
Every setup also writes zitadel.json and the .zitadel/ folder, adds its entries to .gitignore, and adds managed sections to AGENTS.md and README.md, and configures an AI agent in .mcp.json (Connect an AI agent). When setup created the app itself, it also writes app/app.vue and an app/pages/index.vue that redirects to /login.
What the middleware does on each request
/__nextgen/* proxying.useAuth().Component events
The components are plain custom elements, so each event is a DOM CustomEvent that carries its payload in detail. Every SPA SDK exposes the same events and payloads as callbacks.
| Event | Fires when | Detail | Components |
|---|---|---|---|
zitadel-flow-step | Login shows a step, including the first one. | { step } | Login |
zitadel-flow-input | The visitor edits a field. | { name, value } | Login |
zitadel-flow-complete | The flow reaches a terminal step. | { behavior, redirect_uri?, handoff_token?, handoff_token_expires_at? } | Login |
zitadel-flow-redirect | The component hands the browser to an identity provider. Nobody is signed in yet. | { redirect_url, step } | Login |
zitadel-flow-error | The flow reports an error. | { message } | Login |
zitadel-signout | The user signs out. | { display, identifier } | Logout, Session |
zitadel-session-error | Loading the session or signing out failed, other than with no session. | { status?, code?, message, phase } | Logout, Session |
<zitadel-login :project="project" post-sign-in-url="/admin" @zitadel-flow-complete="track" />Check that sign-in works
- Run
npm run dev. Setup already wrote the URL, the project ID and the secret to.env.local. For a manual setup, provide them as the Manual tab describes. - Open
/registeron the dev server, usuallyhttp://localhost:3000/register. Use the origin that setup registered:localhost, not127.0.0.1. - Register a user. A completed sign-in lands on
/profile. - Confirm
/profileshows the signed-in state. - Sign out and confirm protected pages redirect to
/login.
See also
- SDK proxy: why
/__nextgen/*must be same-origin and which call carries the project secret. apps/demo-nuxt: a runnable Nuxt example in this repo.@zitadel/sdk-nuxtsource.
Was this helpful?