Docs

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 --version to check.
  • Nuxt 4 or newer.
  • A Zitadel project from zitadel setup. Start the local runtime with npx @zitadel/cli@latest start, then run npx @zitadel/cli@latest setup --server local in 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.local as ZITADEL_URL, ZITADEL_PROJECT_ID, ZITADEL_PROJECT_SECRET and NUXT_PUBLIC_ZITADEL_PROJECT_ID.

Install the SDK

Setup installs the SDK. To add it yourself, run:

pnpm add @zitadel/sdk-nuxt@latest

Wire 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/.

app/pages/login.vue
app/pages/register.vue
app/pages/profile.vue
nuxt.config.ts
.env.local
.env.example
package.json

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

Register Nitro middleware for same-origin /__nextgen/* proxying.
Validate the session token and attach auth state to the request event.
Copy the auth state into Nuxt state during server rendering, so pages read it with 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.

EventFires whenDetailComponents
zitadel-flow-stepLogin shows a step, including the first one.{ step }Login
zitadel-flow-inputThe visitor edits a field.{ name, value }Login
zitadel-flow-completeThe flow reaches a terminal step.{ behavior, redirect_uri?, handoff_token?, handoff_token_expires_at? }Login
zitadel-flow-redirectThe component hands the browser to an identity provider. Nobody is signed in yet.{ redirect_url, step }Login
zitadel-flow-errorThe flow reports an error.{ message }Login
zitadel-signoutThe user signs out.{ display, identifier }Logout, Session
zitadel-session-errorLoading 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

  1. 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.
  2. Open /register on the dev server, usually http://localhost:3000/register. Use the origin that setup registered: localhost, not 127.0.0.1.
  3. Register a user. A completed sign-in lands on /profile.
  4. Confirm /profile shows the signed-in state.
  5. Sign out and confirm protected pages redirect to /login.

See also

Was this helpful?