Getting Started & Local Setup
This page gets you from a fresh clone to a running dev server. The in-repo guides are the detailed references: README.md for quick start and environment variables, and docs/supabase-local.md for the local database.
Prerequisites
Section titled “Prerequisites”- Node and pnpm at the versions pinned in
package.json(devEnginesandpackageManager). pnpm downloads the right Node if yours doesn’t match. Use pnpm only, never npm or yarn. - Docker and the Supabase CLI, for the local database.
jqandpsqlon yourPATH, if you wantpnpm db:reset-real.
First Run
Section titled “First Run”pnpm install # also installs Husky git hookscp .env.example .env.local # then fill in valuessupabase start # local Postgres, Auth and Storage (needs Docker)pnpm typegen # Next route types + cloudflare-env.d.tspnpm dev # http://localhost:3000.env.example lists the variables, and src/config/env.ts validates them at load time (see Environment & Configuration Constants). Anything prefixed NEXT_PUBLIC_ is inlined into the browser bundle. Keep the service-role key and OAuth secrets unprefixed.
src/types/supabase.ts is committed, so a fresh clone type-checks without a database. cloudflare-env.d.ts is not committed. If the editor can’t find CloudflareEnv or typed route params, run pnpm typegen.
Day-to-Day Database Work
Section titled “Day-to-Day Database Work”flowchart LR
Migration["new migration in<br/>supabase/migrations"] --> Reset["supabase db reset"]
Reset --> Gen["pnpm db:gen"]
Gen --> Types["src/types/supabase.ts"]
Gen --> Schema["docs/db/schema.sql"]
- Run
pnpm db:genafter every migration. Types are derived from the generated file and never hand-written (see Type System & Generated Types). supabase db resetseeds the local DB with the preview fixture.pnpm db:reset-realloads a real data dump instead. Both wipe local data.- If a migration changes what the preview fixture writes, update
supabase/seeds/10-preview-fixture.sqlin the same PR. Otherwise preview deployments break.
See Database Migrations & Seeding for the full workflow.
Before You Push
Section titled “Before You Push”pnpm check # tsc --noEmitpnpm lintpnpm formatpnpm preview # optional: run the real Cloudflare Worker build locallypnpm dev doesn’t run the code the way production does. pnpm preview builds with the OpenNext adapter and serves it with Worker semantics, which catches edge-runtime problems before CI does.
Failure Modes & Edge Cases
Section titled “Failure Modes & Edge Cases”| Symptom | Fix |
|---|---|
CloudflareEnv or route types missing |
pnpm typegen |
pnpm db:gen fails or writes an empty file |
Local Supabase isn’t running; supabase start |
db:reset-real fails immediately |
Install jq and psql |
| Build behaves inexplicably after switching branches or environments | pnpm clean-cache, then pnpm install && pnpm typegen |
document is not defined |
A browser API is used in a Server Component or at module scope; move it into a Client Component |
Related Links
Section titled “Related Links”- Technology Stack & Scripts: what each script does
- Coding Conventions & Linting Rules: rules to know before your first PR
- Supabase Client Patterns: which Supabase client to use where
- docs/workflows.md: branching and PR workflow