AuthTemplate
A Next.js + Supabase starting point with email/password sign-up, login, sessions, and protected routes already wired up โ so you can skip the auth boilerplate and get straight to building. Follow the steps below to connect your own Supabase project and deploy it.
What's included
Everything not marked "delete when ready" is the actual template โ keep it. Click a file or folder with a ๐ก for details.
Setup guide
Prerequisites
node -vInstall Docker Desktop and make sure it's running
Supabase's local stack (Postgres, auth, storage) runs inside Docker containers on your machine.
New to Docker? It packages a program with everything it needs into a self-contained "container," like a lightweight virtual machine. You don't need to learn it โ just:
- Install Docker Desktop
- Open it once so it's running (look for its icon in your menu bar/taskbar)
- Leave it running in the background โ nothing else in this guide asks you to touch it directly
docker infoGet the code
Use this template
Click "Use this template" on GitHub to get your own copy, then clone it.
github.com/rl3020/AuthTemplategit clone <your-repo-url>Local setup
Install dependencies and start local Supabase
npm install pulls down (see package.json for the full list):
- Next.js and React โ the framework
- The Supabase client libraries
- The Supabase CLI itself โ a project dependency, not a global install, so every supabase command here runs through npx
npm installnpx supabase startSet up your env file and run the app
- cp copies .env.example to .env.local โ paste in the Publishable key that supabase start just printed
- npm run dev starts the Next.js dev server, which reads that file and talks to your local Supabase stack, not a production one
cp .env.example .env.localnpm run devCreate a Supabase project
Create the project
Note the Project URL and Publishable key (Project Settings โ API), and the database password (Project Settings โ Database).
supabase.com/dashboardGenerate an access token
Create a personal access token
Scope it to this project โ it's used by GitHub Actions to push migrations.
Account โ Access TokensWire up GitHub Actions
Add three repository secrets
The migration workflow below needs these to authenticate as you and reach your database โ without them it fails with no way to connect.
- Add them at: your GitHub repo โ Settings โ Secrets and variables โ Actions (your repo, not this template's)
- Names must match exactly โ see the panel
SUPABASE_ACCESS_TOKENSUPABASE_PROJECT_REFSUPABASE_DB_PASSWORDYour first migration is already here
This template ships one migration โ you don't need to create it
It's what created the profiles table you saw in "What's included": Row Level Security enabled, plus policies so each user can only read/update their own row.
create table public.profiles ( id uuid primary key references auth.users(id) on delete cascade, display_name text);alter table public.profiles enable row level security;create policy "Users can view their own profile" on public.profiles for select using (auth.uid() = id);create policy "Users can update their own profile" on public.profiles for update using (auth.uid() = id);It goes live the first time the workflow runs
The GitHub Action above applies every file in supabase/migrations/ with supabase db push whenever main gets a commit touching that folder. This one was already committed before you added the secrets, so:
- Re-run the workflow now from your repo's Actions tab, or
- Just wait โ your next real migration will bring this one along too, since db push applies everything not yet applied, not just what changed
Adding your own migration later looks like this
npx supabase migration new add_posts_tablenpx supabase db resetgit add supabase/migrationsgit commit -m "Add posts table"git pushDeploy to Vercel
Import the repo
vercel.com/newAdd environment variables
- NEXT_PUBLIC_SUPABASE_URL โ your hosted project's API URL
- NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY โ the public key from Project Settings โ API (safe to expose client-side โ it's not a secret)
- NEXT_PUBLIC_SITE_URL โ your production domain, used to build the confirmation email link. You won't know this until after the first deploy โ add it and redeploy once you do
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEYNEXT_PUBLIC_SITE_URLAdd your deployed URL to Supabase
Authentication โ URL Configuration โ Redirect URLs โ otherwise the confirmation email link gets rejected.
Configure a real SMTP provider before you launch
Supabase's built-in mailer works out of the box, but it's rate-limited project-wide โ a couple of emails per hour, not per user. Fine for testing, too low for real signups.
Fix โ you're still using Supabase Auth, just supplying your own outbound email server:
- Authentication โ Emails โ SMTP Settings โ point it at your own provider (Resend, SendGrid, Postmark all have free tiers)
- Authentication โ Rate Limits โ raise the limit yourself once you're on your own SMTP