SolidStart is a full-stack web framework built on top of SolidJS that enables you to create performant web applications with a modern development experience. This example demonstrates how to integrate Zitadel using the OAuth 2.0 PKCE flow to authenticate users securely and maintain sessions across the app.
This example shows a complete authentication implementation using SolidStart with Zitadel. Users start on a public landing page and click a login button to authenticate with Zitadel using the secure PKCE flow. The Auth.js library handles the OAuth 2.0 authorization code exchange and manages secure session storage using encrypted JWT tokens. After successful authentication, users are redirected to a protected profile page displaying their user information including OIDC claims like name, email, and custom Zitadel metadata.
The application implements automatic token refresh to maintain long-lived sessions without requiring users to re-authenticate. When an access token expires, the refresh logic seamlessly exchanges the refresh token for new tokens in the background. Route protection is implemented using SolidStart's server functions, ensuring only authenticated users can access sensitive areas. The logout flow implements federated logout with CSRF protection using state parameters, properly terminating both the local session and the Zitadel session before redirecting users back to the application.
Note: Make sure to enable Dev Mode in the Zitadel Console if you're using HTTP URLs during local development. For production, always use HTTPS URLs and disable Dev Mode.