Docs

Angular SDK

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

The Angular SDK (@zitadel/sdk-angular) is the single-page-app wrapper for the shared Zitadel login and logout components, exposed as standalone components. It provides the zitadel-auth-login, zitadel-auth-logout and zitadel-auth-session tags.

SPA proxy requirement

An Angular single-page app has no server of its own. In development, the CLI writes a dev-server proxy config (proxy.conf.cjs) instead of Vite middleware. 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.
  • Angular 19 or newer. To create a new Angular app, use a Node version the Angular CLI accepts (Node versions).
  • 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, the publishable key and the server URL. Setup writes them to .env.local as ZITADEL_PROJECT_ID, ZITADEL_PUBLISHABLE_KEY and ZITADEL_URL. The launcher stops with an error when ZITADEL_PUBLISHABLE_KEY is missing, and the dev proxy when ZITADEL_URL is.

Install the SDK

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

pnpm add @zitadel/sdk-angular@latest

Wire the SDK into your app

The CLI writes the root component (src/app/app.ts), adds auth routes and a proxy config, wires angular.json, adds environment files, and installs the SDK. The component names no project: it imports ZITADEL_PROJECT_ID from src/app/zitadel-project.ts, which setup writes once and zitadel-ng.cjs rewrites from the environment or .env.local before it runs the Angular CLI. Git ignores that file. Setup runs every plain ng serve, ng build or ng test script through zitadel-ng.cjs; a script in another form stays on ng.

src/app/app.ts
src/app/app.html
src/app/app.routes.ts
proxy.conf.cjs
zitadel-ng.cjs
src/app/zitadel-project.ts
angular.json
.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).

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 input in the last column. The callback receives the event's detail payload. The callbacks are inputs and not outputs, so bind the function itself and not a call, and the component registers whatever the callback returns on the detail's waitUntil: an async callback finishes before the widget navigates.

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.

<zitadel-auth-login [project]="project" theme="light" [onFlowComplete]="track" />

Standard HTML attributes

The Angular components are tags (zitadel-auth-login, zitadel-auth-logout and zitadel-auth-session), and a tag already carries the standard HTML attributes. Put class, style, id, data-* or aria-* on it, and Angular applies them to the tag, not to the underlying custom element inside it.

<zitadel-auth-login [project]="project" class="login" data-testid="login" aria-label="Sign in" />

How requests reach Zitadel

The Angular wrapper renders the underlying custom element, which calls the configured proxy path on the same origin.
In development, the generated dev-server 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).

Build for production

Run the app through its npm scripts. npm run build runs node zitadel-ng.cjs build: the Angular CLI reads no environment into client code, so zitadel-ng.cjs reads ZITADEL_PROJECT_ID from the environment, then from .env.local, writes it into src/app/zitadel-project.ts and runs the build.

  • A hosting preset or CI job that runs ng build must run npm run build, and set ZITADEL_PROJECT_ID in the environment where there is no .env.local.
  • On a clean checkout, a plain ng command fails to compile, because src/app/zitadel-project.ts is missing, and npm run build or npm test stops when no ZITADEL_PROJECT_ID is set. After an npm run, a plain ng command reuses the ID that run wrote.
  • Every run writes the same file, so ZITADEL_PROJECT_ID=other npm run build while npm run dev is running makes the dev server reload with the other project.
  • On a machine with .env.local, npm run build puts that file's project ID into the bundle unless the environment sets another.

Render on the server

If your app renders on the server, mount the component on the client only, after hydration. Or pass projectId and proxyPath to the zitadel-auth-login 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.

Check that sign-in works

  1. Run npm run dev. Setup adds a dev script (node zitadel-ng.cjs serve) if your package.json has none.
  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.
  4. Sign out from the session card (zitadel-auth-session) that the generated profile renders. You return to /login.
  5. If you target the elements in browser automation, note the wrapper selectors zitadel-auth-login, zitadel-auth-session and zitadel-auth-logout. The underlying custom elements are zitadel-login, zitadel-session and zitadel-logout.

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?