Supabase Setup Guide
This guide walks you through setting up Supabase for the Next.js & Supabase Boilerplate.
Choose between Local Setup (via Docker) for development/testing or Cloud Setup for production.
What you'll learn: - Local vs. Cloud Supabase setup - Authentication configuration & email templates - Database schema management & seeding - Environment configuration & security best practices
Prerequisites
Required:
- Node.js v22.16.0+
- Supabase account
- VS Code (recommended)
For Local Development:
For Cloud Setup:
- Supabase CLI:
npm install -g supabase
Quick Start
Method | Best For | Time Required |
---|---|---|
Local Setup | Development & Testing | ~5 minutes |
Cloud Setup | Production & Team Collaboration | ~10 minutes |
Local Supabase Setup
Verify Docker Installation
docker --version
docker ps
If Docker isnβt running, open Docker Desktop and wait for it to initialize.
Start Local Supabase
cd nextjs-and-supabase-boilerplate
npm run db:start
This:
- Launches PostgreSQL
- Starts Supabase Auth
- Initializes Edge Functions
- Local dashboard: http://127.0.0.1:54321
Verify Setup
npx supabase status
open http://127.0.0.1:54321
Cloud Supabase Setup
Create a Project
- Go to Supabase Dashboard
- Click New Project
- Fill in name, password, and region
Get API Credentials
- Go to Settings β API
- Copy:
- Project URL
- Anon (public) key
- Service role (secret) key
Never expose your service role key in client-side code.
Install & Authenticate CLI
npm install -g supabase
npx supabase login
Push Schema & Seed Data
cd nextjs-and-supabase-boilerplate
npx supabase db push --include-seed
This applies migrations, RLS policies, and seeds data.
Update .env
SUPABASE_URL="https://your-project-ref.supabase.co"
SUPABASE_ANON_KEY="your-anon-key"
SUPABASE_SERVICE_KEY="your-service-role-key"
Authentication Setup
Enable Email Provider
- Dashboard β Authentication β Providers β Enable Email
- Enable confirmations and set Site URL to your domain
Configure SMTP
Use a provider like Resend, SendGrid, or Postmark:
- Dashboard β Settings β Auth β SMTP Settings
- Enter SMTP credentials
- Save changes
Customize Email Templates
- Copy templates from
/supabase/templates/
(Local) - Paste them into Dashboard β Authentication β Emails
Testing
- Database: Dashboard β Table Editor
- Auth: Dashboard β Authentication β Users
- App: Sign up with a real email
- Email: Check inbox for confirmation
Troubleshooting
Connection Problems
- Check
.env
values - Local: Ensure Docker is running
- Cloud: Confirm project is active
Schema Push Fails
npx supabase login
npx supabase projects list
npx supabase link --project-ref your-project-ref