Authentication

Choose an auth provider and ship login, sessions, protected pages, and OAuth without reinventing the wheel.

Last updated December 18, 2025

At a glance

What you get
  • Login + signup UX
  • OAuth support (e.g. Google)
  • Protected routes and sessions
You'll configure
  • Auth provider keys
  • Redirect URLs
  • Session secret

Quickstart

1
Add environment variables

Add your auth secrets and OAuth keys to .env.local (BETTER_AUTH_SECRET, GOOGLE_CLIENT_ID, etc.).

2
Configure OAuth redirects

Set allowed callback URLs in your provider dashboard (Google, GitHub, etc.).

3
Restart the dev server

Restart npm run dev so environment variables are loaded.

4
Test sign-in flow

Visit /sign-up, create an account, then access a protected page to verify everything works.

Providers

Pick an option below. Each provider has a short guide so you can implement without digging through docs.

Better Auth
Available
Expand

Default in the current scaffold. Database-backed sessions and provider linking.

Supabase Auth
Coming soon
Expand

Magic links + OAuth via Supabase Auth, with a managed user system.

NextAuth
Coming soon
Expand

Popular Next.js auth option with providers and adapter-based persistence.

Code

Copy/paste-friendly code blocks. Designed to get you working quickly without digging through long docs.

Scaffold a new app

Generate a new project and start the dev server.

$ npx saas-scaffold init my-app
$ cd my-app
$ npm run dev
.env.local (auth essentials)

Minimal keys you’ll set for Better Auth + Google OAuth.

# Auth
BETTER_AUTH_SECRET="please-change-me"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"