Skip to main content
Supabase is the foundation of the app. It handles authentication, the main Postgres database, and user/session data used across every product surface.

What Supabase Handles Here

  • sign-in and session cookies
  • user profiles and credits
  • purchases and generations
  • chat history and document metadata

Required Env Vars

NEXT_PUBLIC_SUPABASE_URL=...
NEXT_PUBLIC_SUPABASE_ANON_KEY=...
NEXT_SUPABASE_SERVICE_KEY=...
pnpm exec supabase login
pnpm exec supabase init
pnpm exec supabase link --project-ref your-project-ref
pnpm exec supabase db push

Auth URLs You Must Add

In Supabase Authentication -> URL Configuration, add:
  • Site URL: http://localhost:3000
  • Redirect URL: http://localhost:3000/auth/confirm
And in production:
  • https://yourdomain.com
  • https://yourdomain.com/auth/confirm
The callback route is /auth/confirm, not /auth/complete. The app uses /auth/confirm to exchange the auth code, then redirects into the completion step automatically.

Auth Helpers In The Repo

The main server-side auth helpers live in lib/auth/server.ts. Use these patterns:
  • getAuthContext() when auth is optional
  • requireUser() in server pages and layouts
  • requireApiUser() in API routes
  • signOutCurrentSession() for logout flows

What The Setup Should Create

After pnpm exec supabase db push, you should have the tables needed for:
  • profiles
  • purchases
  • generations
  • chat and document data
  • audio and other app-specific records

Verification

Your Supabase setup is correct if you can:
  • sign in on /auth
  • reach /home
  • see a profile row created for your user
  • use at least one authenticated app flow

Authentication Setup

Need the exact auth flow, magic link setup, and Google OAuth steps?