Docs

Qwik SDK

Client-side Qwik wrappers for the Zitadel login and logout components.

The Qwik SDK (@zitadel/sdk-qwik) is the single-page-app wrapper for the shared Zitadel login and logout components. It exports ZitadelLogin, ZitadelLogout and ZitadelSession as Qwik components.

Requires Qwik 2

@zitadel/sdk-qwik declares @qwik.dev/core (^2.0.0-beta.45) as a peer dependency, so your app must use Qwik 2. A Qwik 1 app (@builder.io/qwik) is not supported. Migrate it to @qwik.dev/core first.

SPA proxy requirement

A Qwik single-page app has no server of its own. In development, the CLI configures a Vite proxy for /__nextgen/*. Production needs a same-origin proxy for /__nextgen/* that forwards the request and adds no credential, as the dev proxy does. The browser sends the publishable key itself. See SPAs in production.

Prerequisites

  • Node.js 24 or newer. Run node --version to check.
  • Qwik 2 (@qwik.dev/core ^2.0.0-beta.45), in an app built with Vite. A Qwik 1 app is not supported.
  • 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 project ID and secret. Setup writes them to .env.local as ZITADEL_PROJECT_ID and ZITADEL_PROJECT_SECRET, and the project ID again as VITE_ZITADEL_PROJECT_ID, the name a Vite app exposes to the browser.

Install the SDK

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

pnpm add @zitadel/sdk-qwik@latest

Wire the SDK into your app

The CLI configures the Vite proxy, writes the app's root component (src/app.tsx) with the /login, /register and /profile pages, adds environment files, and installs the SDK.

src/app.tsx
vite.config.ts
.env.local
.env.example
package.json

In an existing app, the CLI edits the vite.config.* you already have. 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).

Props and events

ZitadelLogin, ZitadelLogout and ZitadelSession take the props below, spelled the same in every SPA SDK. An unset prop keeps the component's own default.

PropTypeDefaultComponentsDescription
projectZitadelProjectunsetLogin, Logout, SessionThe handle that configureZitadel returns. Wins over projectId and proxyPath.
projectIdstringunsetLogin, Logout, SessionThe project ID. Read when you pass no project handle.
proxyPathstring"/__nextgen"Login, Logout, SessionThe same-origin path the component calls.
purposeZitadelFlowPurpose"login"LoginThe purpose of the flow.
flowNamestringunsetLoginRuns the flow definition with this name. Unset runs the project's default flow for the purpose.
postSignInUrlstringunsetLoginWhere to navigate after a completed sign-in. If the page's next query parameter names a path on the same origin, the component goes there instead. The server SDKs' middleware sets next when a signed-out visitor requests a protected route.
forcePostSignInUrlbooleanfalseLoginNavigates to postSignInUrl even when next names a path. Use it on a page that uses next for something of its own.
postSignOutUrlstringunsetLogout, SessionWhere to navigate after sign-out.
resumeFlowIdstring or nullunsetLoginThe ID of an existing flow to resume instead of starting a new one. Unset, null or "" falls back to the flow query parameter. An ID that no longer resolves starts a new flow.
variant"widget" or "page""widget"Login, Sessionwidget is content-sized and paints no page chrome. page claims the viewport, paints the surface background and loads the brand font. On Login, page also focuses the first field.
theme"light", "dark" or "auto"unsetLogin, Logout, SessionThe colour mode. Unset on Login follows the project's branding theme, then the variant default: dark for page, auto for widget. Logout defaults to auto. auto follows prefers-color-scheme.
suppressHeaderbooleanfalseLogin, SessionHides the component's own heading block visually but keeps it in the accessibility tree. Use it on pages that already carry the heading.
suppressPasswordTogglebooleanfalseLoginHides the show/hide button on password fields.
headingstring"Signed in as"SessionOverrides the heading text.
logoutLabelstring"Sign out"SessionOverrides the label of the sign-out action.
localesRecord<string, Partial<Record<string, string>>>unsetLoginCopy overrides, merged over the built-in dictionaries and keyed by primary language subtag. For example, { en: { "identifier.title": "Welcome back" } }.
langstringbrowser languageLoginA BCP-47 language override.

Each component event reaches the callback in the last column. The callback receives the event's detail payload.

EventFires whenDetailComponentsCallback
zitadel-flow-stepLogin shows a step, including the first one.{ step }LoginonFlowStep$
zitadel-flow-inputThe visitor edits a field.{ name, value }LoginonFlowInput$
zitadel-flow-completeThe flow reaches a terminal step.{ behavior, redirect_uri?, handoff_token?, handoff_token_expires_at? }LoginonFlowComplete$
zitadel-flow-redirectThe component hands the browser to an identity provider. Nobody is signed in yet.{ redirect_url, step }LoginonFlowRedirect$
zitadel-flow-errorThe flow reports an error.{ message }LoginonFlowError$
zitadel-signoutThe user signs out.{ display, identifier }Logout, SessiononSignout$
zitadel-session-errorLoading the session or signing out failed, other than with no session.{ status?, code?, message, phase }Logout, SessiononSessionError$

handoff_token is the short-lived credential that a completed flow returns. The proxy exchanges it for a session.

<ZitadelLogin project={project} theme="light" onFlowComplete$={(detail) => track(detail)} />

Standard HTML attributes

ZitadelLogin, ZitadelLogout and ZitadelSession also take the standard HTML attributes (class, style, id, title, slot, hidden, role, tabIndex, data-* and aria-*) and pass them to the component element. You can position, style and label a component without an extra wrapper element. Nothing else reaches the element, so any other prop is ignored.

<ZitadelLogin project={project} class="login" data-testid="login" aria-label="Sign in" />

How requests reach Zitadel

The components call the configured proxy path on the same origin.
In development, the generated Vite proxy forwards /__nextgen/* to Zitadel as a plain rewrite. It adds no credential: the browser sends the publishable key.
In production, you supply the same-origin proxy yourself, as a plain rewrite too (SPAs in production).

Render on the server

If your app renders on the server, pass projectId and proxyPath to the ZitadelLogin wrapper as strings: it writes them as the project-id and proxy-path attributes. Use those hyphenated names only on a raw <zitadel-login> element. A component that starts before its configuration arrives shows an error instead of the flow.

ZitadelLogout and ZitadelSession do the same. The other string and boolean options are written as attributes too: purpose, flowName, postSignInUrl, forcePostSignInUrl, resumeFlowId, postSignOutUrl, variant, theme, heading, logoutLabel, lang, suppressHeader and suppressPasswordToggle. A project handle contributes its projectId, proxyPath, url and publishableKey as attributes. The rest of the handle, and locales, are set as element properties after hydration. So a component that needs locales still gets them only on the client.

Check that sign-in works

  1. Run npm run dev. The app reads the variables that setup wrote to .env.local.
  2. Open the dev server URL, usually http://localhost:3000/register. Use the origin that setup registered: localhost, not 127.0.0.1.
  3. Register at /register, or sign in at /login. A completed sign-in lands on /profile, which shows the signed-in session card.
  4. Sign out from the session card. You return to /login.
  5. In browser automation, use shadow-DOM-aware locators, because the native inputs live inside shared web components.

If sign-in fails in development, run npx @zitadel/cli@latest doctor. doctor --fix repairs a dev proxy that an earlier setup wrote (SDK proxy).

See also

Was this helpful?