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 --versionto 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 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 project ID, the publishable key and the server URL. Setup writes them to
.env.localasZITADEL_PROJECT_ID,ZITADEL_PUBLISHABLE_KEYandZITADEL_URL. The launcher stops with an error whenZITADEL_PUBLISHABLE_KEYis missing, and the dev proxy whenZITADEL_URLis.
Install the SDK
Setup installs the SDK. To add it yourself, run:
pnpm add @zitadel/sdk-angular@latestWire 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.
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.
| Prop | Type | Default | Components | Description |
|---|---|---|---|---|
project | ZitadelProject | unset | Login, Logout, Session | The handle that configureZitadel returns. Wins over projectId and proxyPath. |
projectId | string | unset | Login, Logout, Session | The project ID. Read when you pass no project handle. |
proxyPath | string | "/__nextgen" | Login, Logout, Session | The same-origin path the component calls. |
purpose | ZitadelFlowPurpose | "login" | Login | The purpose of the flow. |
flowName | string | unset | Login | Runs the flow definition with this name. Unset runs the project's default flow for the purpose. |
postSignInUrl | string | unset | Login | Where 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. |
forcePostSignInUrl | boolean | false | Login | Navigates to postSignInUrl even when next names a path. Use it on a page that uses next for something of its own. |
postSignOutUrl | string | unset | Logout, Session | Where to navigate after sign-out. |
resumeFlowId | string or null | unset | Login | The 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, Session | widget 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" | unset | Login, Logout, Session | The 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. |
suppressHeader | boolean | false | Login, Session | Hides the component's own heading block visually but keeps it in the accessibility tree. Use it on pages that already carry the heading. |
suppressPasswordToggle | boolean | false | Login | Hides the show/hide button on password fields. |
heading | string | "Signed in as" | Session | Overrides the heading text. |
logoutLabel | string | "Sign out" | Session | Overrides the label of the sign-out action. |
locales | Record<string, Partial<Record<string, string>>> | unset | Login | Copy overrides, merged over the built-in dictionaries and keyed by primary language subtag. For example, { en: { "identifier.title": "Welcome back" } }. |
lang | string | browser language | Login | A 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.
| Event | Fires when | Detail | Components | Callback |
|---|---|---|---|---|
zitadel-flow-step | Login shows a step, including the first one. | { step } | Login | onFlowStep |
zitadel-flow-input | The visitor edits a field. | { name, value } | Login | onFlowInput |
zitadel-flow-complete | The flow reaches a terminal step. | { behavior, redirect_uri?, handoff_token?, handoff_token_expires_at? } | Login | onFlowComplete |
zitadel-flow-redirect | The component hands the browser to an identity provider. Nobody is signed in yet. | { redirect_url, step } | Login | onFlowRedirect |
zitadel-flow-error | The flow reports an error. | { message } | Login | onFlowError |
zitadel-signout | The user signs out. | { display, identifier } | Logout, Session | onSignout |
zitadel-session-error | Loading the session or signing out failed, other than with no session. | { status?, code?, message, phase } | Logout, Session | onSessionError |
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
/__nextgen/* to Zitadel as a plain rewrite. It adds no credential: the browser sends the publishable key.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 buildmust runnpm run build, and setZITADEL_PROJECT_IDin the environment where there is no.env.local. - On a clean checkout, a plain
ngcommand fails to compile, becausesrc/app/zitadel-project.tsis missing, andnpm run buildornpm teststops when noZITADEL_PROJECT_IDis set. After annpm run, a plainngcommand reuses the ID that run wrote. - Every run writes the same file, so
ZITADEL_PROJECT_ID=other npm run buildwhilenpm run devis running makes the dev server reload with the other project. - On a machine with
.env.local,npm run buildputs 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
- Run
npm run dev. Setup adds adevscript (node zitadel-ng.cjs serve) if yourpackage.jsonhas none. - Open the dev server URL, usually
http://localhost:3000/register. Use the origin that setup registered:localhost, not127.0.0.1. - Register at
/register, or sign in at/login. A completed sign-in lands on/profile. - Sign out from the session card (
zitadel-auth-session) that the generated profile renders. You return to/login. - If you target the elements in browser automation, note the wrapper selectors
zitadel-auth-login,zitadel-auth-sessionandzitadel-auth-logout. The underlying custom elements arezitadel-login,zitadel-sessionandzitadel-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
- SDK proxy: why SPAs need a same-origin
/__nextgen/*proxy and what it must do in production. - Components: the shared web components these wrappers render.
@zitadel/sdk-angularsource.
Was this helpful?