Open source
Next.js + Supabase Starter
Full-stack Next.js starter with Prisma, Redux, and Swagger. Clone it, wire Supabase, and ship to Vercel fast.
View on GitHubProject structure
- docs
- ARCHITECTURE.md
- SECURITY.md
- prisma
- migrations
- 20260630031037_init
- 20260702073512_add_user_and_user_scoped_categories
- migration_lock.toml
- schema.prisma
- public
- file.svg
- globe.svg
- next.svg
- vercel.svg
- window.svg
- src
- app
- api
- categories
- docs
- login
- signup
- favicon.ico
- globals.css
- layout.tsx
- page.tsx
- components
- auth
- categories
- common
- home
- login
- providers
- signup
- lib
- store
- supabase
- api.ts
- openapi.ts
- server
- auth
- controllers
- prisma
- repositories
- types
- swagger-ui-dist.d.ts
- supabase
- .gitignore
- config.toml
- .gitignore
- AGENTS.md
- CLAUDE.md
- eslint.config.mjs
- next.config.ts
- package.json
- postcss.config.mjs
- prisma.config.ts
- README.md
- tsconfig.json
# 1. Clone the project and install dependencies
$ git clone https://github.com/Gazzel16/nextjs-supabase-starter.git
$ cd nextjs-supabase-starter && npm install
# 2. Configure env and start local Supabase
$ cp .env.example .env
$ npx supabase start
$ npx prisma migrate dev && npx prisma generate
# 3. Start the development server
$ npm run dev
→ Local: http://localhost:3000/
→ Docs: http://localhost:3000/docs
✓ Starter ready — open the app and start building!
README
Open on GitHubNext.js + Supabase Starter Template
A full-stack starter template with Next.js 16, TypeScript, Prisma 7, local Supabase (Docker), Redux Toolkit, and OpenAPI/Swagger docs. Clone this repo, update the schema and UI for your domain, and ship to Vercel + Supabase Cloud — no separate backend server required.
For a deep dive into layers, conventions, and how to add new CRUD resources, see docs/ARCHITECTURE.md. For authentication and the Prisma vs RLS model, see docs/SECURITY.md.
Tech stack
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS v4 |
| Database | PostgreSQL via Supabase |
| ORM | Prisma 7 (@prisma/adapter-pg) |
| Client state | Redux Toolkit + React Redux |
| Auth | Supabase Auth (@supabase/ssr) |
| API docs | OpenAPI 3 + Swagger UI (swagger-ui-dist) |
| Deploy | Vercel (app) + Supabase Cloud (database) |
Prerequisites
- Node.js 20+
- Docker (for local Supabase)
- Supabase CLI (run via
npx supabase)
Quick start
git clone <repo-url> my-new-project
cd my-new-project
npm install
cp .env.example .env
npx supabase start
npx prisma migrate dev
npx prisma generate
npm run dev
After npx supabase start, copy the local API URL, anon key, and database URL from the CLI output into your .env file. See .env.example for the required variables.
Auth
- Open http://localhost:3000/signup — enter full name, email, and password
- Or sign in at http://localhost:3000/login
- Auth goes through
POST /api/auth/signuporPOST /api/auth/login(createspublic.userprofile row) /categoriesand/api/categoriesrequire a signed-in session; categories are scoped per user
Local URLs
| Service | URL |
|---|---|
| App | http://localhost:3000 |
| Supabase Studio | http://127.0.0.1:54323 |
| API docs (Swagger) | http://localhost:3000/docs |
| OpenAPI JSON | http://localhost:3000/api/openapi |
Project structure
src/
├── app/ # Routes + API route handlers
│ ├── api/categories/ # HTTP entry (GET/POST/PATCH/DELETE)
│ ├── categories/ # UI page
│ ├── login/ # Sign in
│ ├── signup/ # Sign up
│ └── docs/ # Swagger UI
├── server/ # Backend logic (server-only)
│ ├── auth/ # Session helpers (requireAuthUser)
│ ├── controllers/ # Validation + HTTP responses (categories, auth)
│ ├── repositories/ # Prisma queries (categories, auth)
│ └── prisma/client.ts # Prisma + pg adapter
├── components/ # React UI
│ ├── categories/ # Entity-specific UI (reference CRUD)
│ ├── common/ # Shared UI (AsyncStatus, LogoutButton, etc.)
│ └── providers/ # ReduxProvider
├── lib/supabase/ # Supabase Auth clients (browser, server)
├── lib/store/ # Redux store + slices (API calls in thunks)
└── generated/prisma/ # Prisma client output (do not edit)
prisma/schema.prisma # Database schema
Full architecture guide: docs/ARCHITECTURE.md
Routes
| Route | Purpose |
|---|---|
/ | Home links |
/login | Sign in |
/signup | Create account |
/api/auth/login | Sign in API |
/api/auth/signup | Create account API |
/categories | Categories CRUD UI (auth required) |
/docs | Swagger API docs |
/api/categories | REST API (auth required) |
/api/openapi | OpenAPI JSON spec |
Scripts
| Command | Purpose |
|---|---|
npm run dev | Start dev server |
npm run build | Production build |
npm run start | Run production build locally |
npx supabase start | Start local Postgres + Studio |
npx supabase stop | Stop local Supabase |
npx prisma migrate dev | Apply migrations (development) |
npx prisma migrate deploy | Apply migrations (production) |
npx prisma generate | Regenerate Prisma client |
Deployment (Vercel + Supabase Cloud)
You only need two services — no separate backend on eg. Render, DigitalOcean, or Hostinger.
- Create a Supabase Cloud project and copy the production Postgres connection string.
- Connect this repo to Vercel and deploy.
- Set environment variables in Vercel:
DATABASE_URL— Supabase Cloud Postgres connection stringNEXT_PUBLIC_SUPABASE_URL— Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY— Supabase anon key
- Run migrations against production once:
DATABASE_URL="your-production-url" npx prisma migrate deploy
The deployed Next.js app serves both the UI and /api/* routes. Backend logic in src/server/ runs inside Vercel — not as a separate service.
Adding new resources
The categories module is the reference implementation for full CRUD. To add departments, employees, or any other entity, copy that pattern.
See Adding a new CRUD resource in the architecture guide.
Cloning for a new project
When you fork or clone this repo for a new app:
- Update app title/metadata in
src/app/layout.tsxandsrc/app/page.tsx - Edit
prisma/schema.prismafor your domain models - Run
npx prisma migrate devafter schema changes - Copy the
categoriespattern for each new entity (backend + frontend + Redux slice) - Extend
src/lib/openapi.tswith new API paths - Update
.envlocally and env vars on Vercel