Qwik Router SDK
An onRequest plugin and helpers for Qwik Router (formerly Qwik City) applications.
The Qwik Router SDK is an onRequest plugin that proxies and verifies sessions on the server. The login and logout widgets come from the Qwik SDK.
Qwik 2 required
The SDK peers Qwik 2: @qwik.dev/core and @qwik.dev/router (Qwik Router, which Qwik 2 renamed from Qwik City). A Qwik 1 app (@builder.io/qwik-city) is not supported, because the widgets need Qwik 2. Migrate the app to @qwik.dev/* first. The CLI scaffolds new apps on Qwik 2.
Install
Install both packages as dev dependencies. Qwik bundles devDependencies into the server build, and its starter vite.config.ts refuses to start when a package is listed in both sections.
pnpm add -D @zitadel/sdk-qwik-router@latest @zitadel/sdk-qwik@latestSetup
The CLI adds the plugin, the routes, environment files, and both SDK packages. No config file changes: Qwik Router picks up plugin@*.ts route files on its own.
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.
Runtime model
/__nextgen/* requests to the backend, attaching the project secret only to the session handoff.sharedMap; read it with getAuth(ev) in a routeLoader$, action, or endpoint.protectedRoutes to loginPath, with the requested path and query string in ?next=, where the login widget returns after sign-in. A route matches with or without a trailing slash, since Qwik Router serves /profile/ by default.Verify
- Start the app with
npm run dev. Setup already wrote the URL, the secret, and the project id to.env.local. - Visit
/loginand register a user. - Confirm
/profileshows signed-in state. - Log out and confirm
/profileredirects to/login.
See also
- SDK proxy — why
/__nextgen/*must be same-origin and which call carries the project secret. @zitadel/sdk-qwik-routersource and the CLI Qwik Router patcher.
Was this helpful?