Authentication
Understand provider-specific routes, clients, sessions, and environment variables.
Provider comparison
| Provider | Model | Database requirement | Generated sign-in experience |
|---|---|---|---|
| Better Auth | Self-hosted | Required | Email and password pages under /login and /register |
| Clerk | Hosted | Optional | Clerk catch-all routes under /sign-in and /sign-up |
| NextAuth | Self-hosted | Required by the generated adapter | Provider flow through Auth.js routes |
Better Auth
Set BETTER_AUTH_SECRET to at least 32 characters and set BETTER_AUTH_URL to the application origin. The generated client is available under src/modules/auth/client, while server configuration stays under src/modules/auth/server.
After changing the auth schema, run:
npx better-auth generateClerk
Set CLERK_SECRET_KEY and NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY. Nextron wraps the root layout with ClerkProvider and generates provider-native account UI.
NextAuth
Set AUTH_SECRET, then configure OAuth credentials for the providers enabled in src/modules/auth/server/auth.ts. Nextron adds SessionProvider to the root layout for client session access.
Route protection
When Dashboard is selected, Nextron generates middleware matched to the chosen provider. The middleware protects /dashboard and /settings without mixing APIs from another auth implementation.