Docs
Guides
Authentication
Authentication
Configure secure user authentication for your application.
This template comes pre-configured with authentication support. We typically use robust solutions like NextAuth.js (Auth.js) or Clerk depending on the specific product.
Environment Variables
To enable authentication, you need to set up the necessary environment variables in your .env file.
.env
# NextAuth Secret (generate with: openssl rand -base64 32) NEXTAUTH_SECRET="your-secret-key" NEXTAUTH_URL="http://localhost:3000" # OAuth Providers (examples) GITHUB_ID="" GITHUB_SECRET="" GOOGLE_CLIENT_ID="" GOOGLE_CLIENT_SECRET=""
Configuring Providers
Authentication providers are configured in src/lib/auth.ts or src/app/api/auth/[...nextauth]/route.ts.
You can add or remove providers by importing them from next-auth/providers and adding them to the providers array in the configuration object.
Protecting Routes
You can protect routes using middleware or server-side checks.
Middleware Example
See src/middleware.ts for the current protection logic.