mirror of
https://github.com/TanStack/router.git
synced 2026-11-16 19:38:07 +00:00
ci: changeset release Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
History
|
|
|---|---|---|
| .. | ||
| .devcontainer | ||
| .vscode | ||
| prisma | ||
| public | ||
| src | ||
| .env | ||
| .gitignore | ||
| .prettierignore | ||
| dev.db | ||
| package.json | ||
| prisma.config.ts | ||
| README.md | ||
| tsconfig.json | ||
| vite.config.ts | ||
TanStack Start - Basic Auth Example
A TanStack Start example demonstrating authentication patterns and protected routes.
Start a new project based on this example
To start a new project based on this example, run:
npx gitpick TanStack/router/tree/main/examples/react/start-basic-auth start-basic-auth
Getting Started
From your terminal:
pnpm install
pnpm dev
This starts your app in development mode, rebuilding assets on file changes.
Build
To build the app for production:
pnpm build
Authentication Features
This example demonstrates:
- User authentication flow
- Protected routes
- Login/logout functionality
- Redirect after authentication
Session configuration
This example uses iron-session through Start's getCookie and setCookie helpers. Set SESSION_PASSWORD to a random secret of at least 32 characters before starting the app, for example:
export SESSION_PASSWORD="$(openssl rand -base64 32)"
Keep the same secret across instances and deployments that must read the same sessions. The cookie requires HTTPS in production. Each handler reads its own session, then awaits session.save() before redirecting or returning.