Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

nextbase-nextjs-supabase-starter

> 前端框架
Open source

⚡️ Free Boilerplate and Starter kit for Next.js 16+, Supabase, Tailwind CSS 4 and TypeScript. Next.js Supabase TypeScript ESLint Prettier Hu

800 stars0 likes2 views
WebsiteGitHub

About

⚡️ Free Boilerplate and Starter kit for Next.js 16+, Supabase, Tailwind CSS 4 and TypeScript. Next.js Supabase TypeScript ESLint Prettier Hu

NextBase Starter — Open Source Next.js + Supabase Boilerplate

A production-grade Next.js 16 + Supabase foundation. Free, MIT-licensed, and ready to clone.

NextBase Starter is the open-source baseline of the NextBase family — an opinionated, tested starting point for SaaS teams building on Next.js 16 and Supabase. It bundles the auth, RLS, monorepo, and caching patterns that you would otherwise spend weeks deriving from scratch.

  • Demo: [live demo URL]
  • Documentation: [docs URL]
  • Changelog: see CHANGELOG.md
  • License: MIT — see LICENSE

Need more than the starter? Stripe billing, teams & orgs, RBAC admin, transactional emails, multi-tenancy, AI starter kits — all built on the same patterns — ship as premium NextBase kits. → See the premium kits at usenextbase.com


Why this exists

Every SaaS team writes the same code in the first sprint and the same code in the first incident:

  • A "simple" Supabase auth integration that quietly breaks SSR cookies after a refresh, then again after a deploy.
  • An RLS policy that looked right in review and silently leaked a row in production.
  • A server-action layer that was supposed to be type-safe but ended up being three subtly different patterns across the codebase.
  • A monorepo that started clean and devolved into a tangle of relative imports and untyped envs.
  • A "we'll add caching later" that turns into a revalidatePath archaeology dig six months in.

NextBase compresses all of that prior art into a maintained, opinionated starter. You inherit decisions that have already failed in production somewhere else, so they don't have to fail in yours.


Features

Authentication

  • Supabase Auth, SSR-correct. @supabase/ssr clients for browser, server components, server actions, and middleware — wired so cookies survive every render boundary in Next.js 16.
  • Multiple sign-in methods out of the box: email + password, passwordless magic link, and OAuth (Google, GitHub, Twitter — add more in minutes).
  • Hardened middleware. A single source of truth for protected routes (/dashboard, /private-item, /private-items, …) using path-to-regexp matching and supabase.auth.getUser() re-verification on every request.
  • Battle-tested flows. Sign-up, sign-in, sign-out, email confirmation, forgot-password, update-password, and OAuth callback / code-error pages — all implemented as Server Actions and tested.

Database, Permissions & Multi-Tenancy

  • Supabase Postgres with Row Level Security from day one. Every user-owned table ships with SELECT/INSERT/UPDATE/DELETE policies keyed off auth.uid().
  • Versioned migrations. Real timestamped SQL migrations under apps/database/supabase/migrations — not a hand-edited single file.
  • Generated database types. pnpm gen-types (remote) and pnpm gen-types-local (local) regenerate database.types.ts so every query is end-to-end typed.
  • pgTAP-ready test harness. A test scaffold under apps/database/supabase/tests for asserting RLS policies, triggers, and constraints.
  • updated_at triggers standardized via a single public.set_updated_at() function — applied per-table, not duplicated.

Server Actions, Validation & Data Layer

  • next-safe-action everywhere. All mutating endpoints are Zod-validated, typed end-to-end, and ship with two pre-built clients:
    • actionClient — base client with development-time perf + payload logging middleware.
    • authActionClient — extends the base client and injects ctx.userId for the current user, refusing unauthenticated calls.
  • Clean data-access separation. Queries are partitioned by trust boundary:
    • src/data/anon/* — anonymous, public reads
    • src/data/auth/* — authentication flows (sign-in, sign-up, sign-out)
    • src/data/user/* — authenticated user data (RLS-enforced)
    • src/rsc-data/* — React Server Component data fetchers
  • Optional effect-ts integration. Composable Effect-based query helpers and typed Supabase error mapping under src/utils/effect-* for teams that want railway-oriented data flow without leaking it into every file.

Caching, Performance & UX

  • Next.js 16 Cache Components (cacheComponents: true). Static-by-default rendering with surgical "use cache" boundaries, plus a written guide (docs/NEXTJS_CACHE_COMPONENTS.md) explaining exactly when and how to use each primitive.
  • Suspense-first data fetching via createSuspenseResource and TanStack Query — clean loading boundaries, no waterfall fetches.
  • Turbopack dev server for sub-second HMR on real-world component trees.
  • Optimized next/image remote patterns preconfigured for Supabase Storage and Unsplash.

UI & Developer Experience

  • shadcn/ui pre-installed with the full Radix primitive set (40+ components: dialogs, command palettes, sidebars, sheets, toasts, hover cards, OTP input, …) — ready to copy, paste, and customize.
  • Tailwind CSS v4 via @tailwindcss/postcss, including @tailwindcss/forms and @tailwindcss/typography.
  • Framer Motion, Embla Carousel, cmdk, input-otp, Lucide icons, date-fns, React Hot Toast — the entire baseline UI toolkit you would have installed in week one.
  • React Bits animated components (BlurText, ShinyText, SpotlightCard) installed via the shadcn registry and used on the home page and login screen.
  • TypeScript with shared packages/typescript-config, oxlint + oxfmt (Oxc-based, ~50× faster than ESLint+Prettier), and centralized Zod schemas in src/utils/zod-schemas.
  • Tested. Vitest + Testing Library for unit, Playwright for E2E — both already wired into Turbo pipelines.

Infrastructure, Observability & Releases

  • Turborepo monorepo (apps/*, packages/*) with pnpm workspaces and pipelined build, lint, test, typecheck, gen-types, test:e2e tasks.
  • Local Supabase stack lifecycle scripts: pnpm database#start | stop | status.
  • Changesets-based release automation. Every shippable change ships with a changeset; an automated "Version Packages" PR rolls them into a single bumped release, syncs apps/web versions, and cuts a GitHub release.
  • GitHub Actions starter workflows (Playwright + coverage) included.
  • SEO baked in: next-seo, next-sitemap postbuild, JSON-LD and Open Graph helpers.

Screenshots

Replace these placeholders with your branded captures once you customize the marketing surfaces.

Landing & marketing — the (external-pages) route group, including the home page and /about, ready to be replaced with your positioning. [screenshot]
Authentication — login / sign-up / magic-link / forgot-password screens with provider buttons (Google, GitHub, Twitter). [screenshot]
Dashboard — the authenticated (app-pages) shell with sidebar, breadcrumbs, and a CRUD reference page. [screenshot]
Private items CRUD — RLS-protected list, detail (/private-item/[id]), and create-new flows demonstrating the full data path. [screenshot]

Tech stack

Layer Choice
Framework Next.js 16 (App Router, Cache Components, Turbopack)
UI runtime React 19
Language TypeScript (strictNullChecks enabled)
Database & Auth Supabase (Postgres, RLS, Auth, Storage)
Auth SSR @supabase/ssr
Server Actions next-safe-action + Zod
Effects (optional) effect + @effect/platform
Data fetching TanStack Query + React Suspense
UI primitives shadcn/ui on Radix UI
Styling Tailwind CSS v4 (PostCSS) + Tailwind Forms / Typography
Forms React Hook Form + Zod resolvers
Animation Framer Motion
Lint / Format oxlint + oxfmt
Unit / Integration tests Vitest + Testing Library + jsdom
E2E tests Playwright
Monorepo Turborepo + pnpm workspaces
Releases Changesets
SEO next-seo, next-sitemap

Architecture overview

NextBase is a Turborepo with two apps and shared config packages.

…

Auth flow

  1. Middleware (src/supabase-clients/middleware.ts) instantiates a server Supabase client, calls auth.getUser() to re-verify the session, and redirects unauthenticated visitors away from protected route prefixes.
  2. Server components call createSupabaseClient() to read data under the user's RLS context.
  3. Server actions use authActionClient from lib/safe-action.ts, which short-circuits unauthenticated callers and injects ctx.userId.
  4. OAuth & email confirmation complete at /auth/callback and /auth/confirm, with /auth/auth-code-error for failures.

Permissions model

Authorization is enforced at the database layer via Postgres RLS — not in handler code. Every user-owned table has explicit SELECT/INSERT/UPDATE/DELETE policies that compare auth.uid() to ownership columns. Service-role access is gated separately. This means a forgotten check in a route handler cannot exfiltrate data; the database refuses the read.

Caching strategy

With cacheComponents enabled, route segments are static by default. Static UI (sidebars, breadcrumbs, headings, marketing) is marked "use cache". Personalized data leaves caching off and uses Suspense. Cache invalidation happens via revalidatePath() from server actions. The full mental model is documented in docs/NEXTJS_CACHE_COMPONENTS.md.

Server / client boundary

  • lib/safe-action.ts and all data/* modules are 'use server' or import 'server-only'. They never leak into a client bundle.
  • Client interactivity is co-located: ClientPage.tsx, *-client.tsx, and explicit 'use client' directives.
  • Browser Supabase access uses supabase-clients/client.ts; server uses supabase-clients/server.ts (cookies wired via next/headers).

Quick start

1. Install

bash
pnpm install

2. Configure environment

Copy the examples and fill in your Supabase project details:

bash
cp .env.local.example .env.local
cp .env.development.local.example .env.development.local

Required variables:

SUPABASE_PROJECT_REF=
NEXT_PUBLIC_SUPABASE_URL=.supabase.co | http://localhost:54321>
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=

3. Provision the database

Option A — Local stack (recommended for development):

bash
pnpm database#start
pnpm gen-types-local

Option B — Hosted Supabase project:

bash
pnpm supabase link --project-ref $SUPABASE_PROJECT_REF
pnpm supabase db push
pnpm gen-types

4. Run the app

bash
pnpm dev
# → http://localhost:3000

5. Test

bash
pnpm test          # Vitest unit / integration
pnpm test:e2e      # Playwright end-to-end
pnpm typecheck     # tsc --noEmit across the monorepo
pnpm lint          # oxlint

6. Deploy

NextBase deploys to any Node 22+ host. Vercel is the path of least resistance:

  • Set the same env vars as production secrets.
  • Point your custom domain at the deployment.
  • Configure the Supabase project's allowed redirect URLs (/auth/callback).

React Bits

The marketing and auth surfaces use animated components from React Bits, installed through the shadcn community registry.

Installed components:

  • BlurText — blur-to-focus word reveal
  • ShinyText — metallic shine sweep
  • SpotlightCard — cursor-following radial spotlight

They are used in:

  • apps/web/src/app/(external-pages)/home-hero.tsx
  • apps/web/src/app/(external-pages)/home-cta.tsx
  • apps/web/src/app/(auth-pages)/login/Login.tsx

Add more React Bits components with the shadcn CLI:

bash
cd apps/web
pnpm dlx shadcn@latest add @react-bits/-TS-TW

The registry is already configured in apps/web/components.json:

json
{
  "registries": {
    "@react-bits": "https://re

Issues· 38 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptboilerplateboilerplate-reacteslintjamstack

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架