Overview
If you prefer not to use Dev Containers, or if you’re working on a system without Docker, you can set up the Auth UI Boilerplate manually. This guide covers installation on macOS, Linux, and Windows.The Dev Container setup is recommended for most users as it ensures a consistent environment. Only use manual setup if you have specific requirements or cannot use Docker.
Prerequisites
Before you begin, ensure you have the following installed on your system:Node.js 22+
JavaScript runtime (LTS version recommended)
PostgreSQL
Relational database (version 14+ recommended)
Git
Version control system
npm or pnpm
Package manager (included with Node.js)
Verify Prerequisites
Confirm that you have the required versions installed:Installation Steps
Set Up PostgreSQL Database
Create a new PostgreSQL database for the application.
Option 1: Using psql (Command Line)
Option 2: Using pgAdmin (GUI)
- Open pgAdmin and connect to your PostgreSQL server
- Right-click Databases → Create → Database
- Name:
auth_boilerplate - Owner:
postgres(or create a dedicated user) - Click Save
Option 3: Using Docker (Standalone PostgreSQL)
If you have Docker but don’t want the full Dev Container:The database name doesn’t have to be
auth_boilerplate — use whatever name you prefer, and update DATABASE_URL accordingly.Configure Environment Variables
Copy the example environment file:Open Copy the output and replace
.env in your editor and update the DATABASE_URL to match your local PostgreSQL configuration:.env
Generate Better Auth Secret
Use OpenSSL to generate a secure random secret:BETTER_AUTH_SECRET in .env.Set Up Google OAuth (Optional)
To enable Google sign-in:- Go to Google Cloud Console
- Create OAuth 2.0 credentials (see Quickstart guide for detailed steps)
- Set redirect URI to
http://localhost:3000/api/auth/callback/google - Copy Client ID and Secret to
.env
Google OAuth is optional. You can use email/password authentication without it.
Install Dependencies
Install all required npm packages:This installs all dependencies defined in
package.json, including:- next (v16.1.6) — React framework
- better-auth (v1.4.18) — Authentication library
- drizzle-orm (v0.45.1) — Database ORM
- pg (v8.18.0) — PostgreSQL client
- axios (v1.13.5) — HTTP client
- tailwindcss (v4) — CSS framework
- lucide-react — Icon library
Push Database Schema
Create the required database tables:This runs Expected output:
drizzle-kit push, which:- Connects to your PostgreSQL database using
DATABASE_URL - Reads the schema from
src/db/schema.ts - Creates tables:
user,session,account,verification,jwks
Verify Tables
Check that the tables were created:Start the Development Server
Run the Next.js development server:The application will start on http://localhost:3000.Expected output:
The first start may take longer as Next.js compiles the application. Subsequent starts will be faster.
Verify Installation
Open your browser and navigate to http://localhost:3000.You should see the Auth UI Boilerplate home page with:
- Navigation bar with Sign In and Sign Up buttons
- “How It Works” section
- Backend integration guides
- Theme toggle (light/dark mode)
Test Authentication
- Click Sign Up and create an account with email/password
- After signup, you should be automatically signed in
- Verify your session appears in the “Authentication Status” card
- Test sign out and sign in again
Test Google OAuth (if configured)
- Click Sign In
- Click Sign in with Google
- Complete the OAuth flow
- Verify you’re redirected back and authenticated
Database Management Commands
The boilerplate includes several Drizzle commands for managing your database:| Command | Description |
|---|---|
npm run db:push | Push schema changes directly to database (dev only) |
npm run db:generate | Generate SQL migration files from schema changes |
npm run db:migrate | Apply pending migrations to the database |
npm run db:studio | Open Drizzle Studio (visual database browser) |
Drizzle Studio
To visually browse and edit your database:- View all tables and data
- Edit records directly
- Run queries
- Inspect relationships
Production Deployment
For production deployments:-
Use migrations instead of push:
-
Set environment variables on your hosting platform:
DATABASE_URL— Production PostgreSQL connection stringBETTER_AUTH_SECRET— Strong random secret (32+ characters)BETTER_AUTH_URL— Production URL (e.g.,https://app.example.com)NEXT_PUBLIC_BETTER_AUTH_URL— Same asBETTER_AUTH_URLGOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET— Update redirect URI to production URL
-
Update Google OAuth redirect URI:
-
Build and start:
Troubleshooting
Connection refused to PostgreSQL
Connection refused to PostgreSQL
Symptoms:
Error: connect ECONNREFUSED 127.0.0.1:5432Solutions:- Ensure PostgreSQL is running:
sudo service postgresql status(Linux) or check Activity Monitor (macOS) - Verify the port: PostgreSQL defaults to 5432, but check your config
- Check
DATABASE_URLformat:postgresql://user:password@host:port/database - Try connecting with psql:
psql -U postgres -h localhost
Authentication failed for user
Authentication failed for user
Symptoms:
error: password authentication failed for user "postgres"Solutions:- Verify your PostgreSQL password is correct in
DATABASE_URL - Reset the postgres password:
- Update
.envwith the new password
Node.js version too old
Node.js version too old
Symptoms:
Error: The engine "node" is incompatible with this moduleSolutions:- Upgrade to Node.js 22+: Download from nodejs.org
- Or use nvm (Node Version Manager):
- Verify:
node --version
Port 3000 already in use
Port 3000 already in use
Symptoms:
Error: listen EADDRINUSE: address already in use :::3000Solutions:- Find and kill the process using port 3000:
- Or run on a different port:
drizzle-kit command not found
drizzle-kit command not found
Symptoms:
bash: drizzle-kit: command not foundSolutions:- Run via npm script:
npm run db:push(notdrizzle-kit push) - Or install globally:
npm install -g drizzle-kit - Verify installation:
npx drizzle-kit --version
What’s Next?
Environment Variables
Detailed guide to all configuration options
Database Schema
Learn how to add custom tables with Drizzle
Backend Integration
Connect Go, Python, or Node.js backends
Dev Container Setup
Alternative setup using Dev Containers