A Next.js application with Supabase authentication and Drizzle ORM.
- Node.js 18+
- A Supabase project
-
Install dependencies
npm install
-
Configure environment variables
Copy the example environment file and fill in your Supabase credentials:
cp .env.example .env.local
Required variables:
NEXT_PUBLIC_SUPABASE_URL- Your Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY- Your Supabase anonymous keyDATABASE_URL- Your Supabase PostgreSQL connection string
-
Set up the database
Generate migrations from the schema:
npm run db:generate
Apply migrations to your database:
npm run db:migrate
Or push schema directly (for development):
npm run db:push
-
Add foreign key constraint for Supabase auth
Run this SQL in your Supabase SQL Editor to link the users table to Supabase auth:
ALTER TABLE public.users ADD CONSTRAINT users_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;
-
Run the development server
npm run dev
Open http://localhost:3000 in your browser.
| Command | Description |
|---|---|
npm run db:generate |
Generate migrations from schema |
npm run db:migrate |
Apply migrations to database |
npm run db:push |
Push schema directly (dev only) |
npm run db:studio |
Open Drizzle Studio GUI |
- Next.js - React framework
- Supabase - Authentication and PostgreSQL database
- Drizzle ORM - TypeScript ORM
- Tailwind CSS - Styling