Supabase Auth email magic link sign-in, no password management required
nextjs-supabase-auth-starter — Next.js SaaS Template
By RCushmaniii
An authentication starter built on Next.js App Router and Supabase, focused on email magic link sign-in, SSR session refresh, and RLS database policies, with protected routes and an optional admin boundary example.
Explore the design
Compare the page layouts and mobile experience. Open any screenshot for a closer look.
Actual screenshot captured by the server browser.
All pages & views 3
Screenshots show visual appearance; interactive behavior may differ.
What stands out
A quick read of the recorded project description.
SSR session refresh via @supabase/ssr in middleware.ts
Built-in SQL migrations: profiles and notes tables with RLS enabled by default and per-user isolation
Provides a protected /app route and an /admin admin boundary example based on profiles.role
Bilingual English/Spanish UI with language preference persisted via cookie
Environment variables validated with Zod; CI includes typecheck, lint, and build
Template Details
This is a Next.js starter template centered on authentication and database security. It uses the App Router with TypeScript (strict), implements passwordless email magic link sign-in via Supabase Auth, and refreshes SSR sessions in middleware.ts using @supabase/ssr. The template includes SQL migrations that create a profiles table (one-to-one with auth.users), an app_role enum (user/admin), a trigger that automatically creates a profile when a new user registers, and a notes demo table. Both tables have RLS enabled by default with per-user isolation policies.
At the routing level, it provides a public landing page, an about page, a magic link explanation page, a sign-in page, a protected /app route requiring authentication, and an admin route /admin controlled by profiles.role. The UI supports English and Spanish with a language toggle, and the language preference is persisted via cookie. Environment variables are validated with Zod, and CI covers typecheck, lint, and build.
Before use, you must provide your own Supabase project (hosted or local) and run the two migration files; otherwise only public pages will render, and authentication and protected routes will be unavailable. The template explicitly does not include billing, teams, subscriptions, multi-tenant RBAC, and is not a shadcn/ui design system, UI component library, CMS, or general-purpose Next.js boilerplate.
Is it right for your project?
Use Cases
- As a starting point for MVPs that need real authentication and database row-level security
- To demonstrate how Supabase RLS isolates data per user
- To verify how magic link sign-in and SSR session refresh work together in Next.js
- As a reference implementation of an authentication flow with an admin role boundary
Suitable For
- Developers who plan to set up their own Supabase project and need an authentication skeleton
- Teams that want to build the data layer with RLS as a default assumption
- Next.js projects that need a bilingual (English/Spanish) UI foundation
Getting started & customization
Use these recorded setup notes alongside the repository instructions for your chosen version.
- 1
Copy .env.example to .env.local and fill in NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY (the legacy anon key is still supported)
- 2
Run the init.sql and notes.sql migrations under supabase/migrations in order in Supabase
- 3
Add the /auth/callback redirect URL in Supabase Auth settings; for local development, use http://localhost:3000/auth/callback
- 4
To grant admin privileges, update the role of the corresponding user in the profiles table to admin in the SQL editor
- 5
Without a configured Supabase project and environment variables, only public pages render; authentication and protected routes are unavailable
License & source material
Usage conditions & limitations
Free to use · keep license noticeThis listing covers the free version under the MIT license in the public repository; the free scope applies to that version's code and does not imply that external services or third-party assets are free.
Must comply with when using
- You may use, modify, commercialize, and distribute this version's code for free.
- When distributing copies or substantial portions of the code, retain the original author's copyright notice and the full MIT license notice.
- The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.
Additional costs & items to verify
- Using this template requires your own Supabase project (hosted or local); the project itself does not provide a database backend.
- Without a configured Supabase project and environment variables, only the public landing page renders; authentication and protected routes are unavailable.
- To deploy a public demo that supports real sign-in, a hosted Supabase project is required.
- Deploying a public demo requires a hosted Next.js deployment environment (Vercel recommended).
- The /auth/callback redirect URL must be configured in Supabase Auth settings; otherwise magic link sign-in cannot complete.
- This starter does not require a service role key; if you add one later, never expose it to the browser.
- Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses; the code's MIT license alone is not sufficient to judge them.
- External services such as domains, hosting, databases, payments, or AI may incur additional charges.
View Original Text Basis
Permission is hereby granted, free of charge
Original License Text
You bring your own Supabase project (hosted or local).
Original README
Without a Supabase project + env vars, the public landing page will render, but auth and protected routes will not be functional.
Original README
A hosted Supabase project
Original README
A hosted Next.js deployment (Vercel recommended)
Original README
Add these redirect URLs in Supabase Auth settings:
Original README
https://github.com/RCushmaniii/nextjs-supabase-auth-starter/blob/main/LICENSEhttps://github.com/RCushmaniii/nextjs-supabase-auth-starter/blob/main/README.mdThis starter does not require a service role key.
Original README
Compiled by DeepSeek based on repository license and README ·2026-10-01. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.
Project checks & description sources
Template Information
- Source platforms
- GitHub
- Documentation and maintenance reference score
- More documented · 85 / 100
- Technologies
- Next.js · React
- Website type
- SaaS · Starter
How this score is calculated
Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.
What to verify for this project
- Repository update recorded
- 2026-09-12
- Screenshot last checked
- 2026-10-01
A demo link is listed. Check it with your own content and viewport sizes; its presence does not confirm that forms, authentication or payments work.
The catalog identifies Next.js as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.
Use a selection guide →How this description was prepared
AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.
Automatically checked against source and license rules; no manual editorial review.
Inspect the recorded source material
SHA-256: a3580979095bb18d28a394385cc4d0509e3c1b2b7035b8366ce200ed37bc497f
2026-10-01T00:58:42.166Z
Source file / repository# Next.js Supabase Auth Starter (CushLabs.ai) A minimal, production-minded Next.js App Router starter focused on **Supabase Auth**, **SSR session refresh**, and an **RLS-first database posture**. Built as a clean, modern demo you can fork for MVPs. ## Live Demo - **App**: https://nextjs-supabase-auth-starter.vercel.app - **About**: https://nextjs-supabase-auth-starter.vercel.app/about - **Why Magic Links**: https://nextjs-supabase-auth-starter.vercel.app/why-use-magic-links ## Screenshots ### Sign In Page <img src=".github/images/login.jpg" alt="Sign In Page" width="370"> ## Why this starter - **Secure by default** - RLS-first database posture (no “turn off RLS to make it work” shortcuts) - **SSR-ready auth** - Middleware-based session refresh via `@supabase/ssr` - **Realistic gating patterns** - Protected routes (`/app`) and optional admin boundary (`/admin`) - **Demo-friendly UX** - Bilingual UI (EN/ES) with cookie persistence - Simple, responsive public layout (mobile hamburger nav) ## Features - Next.js 14 App Router + TypeScript (strict) - **Passwordless Authentication**: Supabase Auth with email magic links (no passwords to manage) - SSR-friendly session refresh in `middleware.ts` via `@supabase/ssr` - Protected routes example (`/app`) - Optional admin boundary example (`/admin`) gated by `profiles.role` - **Bilingual Support**: Full i18n implementation (English/Spanish) with cookie persistence - RLS-first migrations included: - `profiles` table + role enum + trigger + RLS policies - `notes` table with strict per-user RLS policies (RLS proof playground) - Environment variable validation (Zod) - Minimal CI: `typecheck`, `lint`, `build` ## What This Repo Is This repo IS: - A minimal, production-minded auth + RLS starter - A good base to clone for MVPs where you want real auth and real DB security ## What This Repo Is Not - A shadcn/ui starter or design system template - A full SaaS product (billing, teams, subscriptions, multi-tenant RBAC) - A UI kit / component library - A CMS/blog starter - A general-purpose Next.js boilerplate ## BYO Supabase (How Templates Work) This is a template repo. - You bring your own Supabase project (hosted or local). - This repo provides the schema + RLS via SQL migrations. Without a Supabase project + env vars, the public landing page will render, but auth and protected routes will not be functional. ## Demo walkthrough (what to try) - **1) Sign in** - Go to `/sign-in` and request a magic link - **2) Prove SSR session refresh** - Visit `/app` (protected) - Refresh the page; you should remain signed in (middleware refresh) - **3) Prove RLS per-user isolation** - Create notes under your account - Sign in as a different user; you should not see the other user’s notes - **4) Optional: admin gating** - Promote a user to `admin` in `profiles` - Visit `/admin` ## Quickstart ### 1) Install dependencies ```bash npm install ``` ### 2) Configure env Copy `.env.example` to `.env.local` and fill in values: PowerShell: ```powershell Copy-Item .env.example .env.local ``` macOS/Linux: ```bash cp .env.example .env.local ``` Required: - `NEXT_PUBLIC_SUPABASE_URL` - `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` (preferred, `sb_publishable_...`) Legacy (still supported): - `NEXT_PUBLIC_SUPABASE_ANON_KEY` (legacy `anon` JWT key) Optional: - `NEXT_PUBLIC_APP_URL` (useful as a fallback for auth redirect URL; set it to `http://localhost:3000` in dev) ### 3) Apply the database migration (RLS included) Run: - `supabase/migrations/20251214190000_init.sql` - `supabase/migrations/20251216010600_notes.sql` Apply it via: - Supabase Dashboard SQL editor, or - Supabase CLI migrations What it does: - Creates `public.app_role` enum (`user`, `admin`) - Creates `public.profiles` (1:1 with `auth.users`) - Enables RLS on `public.profiles` - Adds policies for users to read/update their own profile (admins can read/update all) - Adds a trigger to create `profiles` rows on new user signup - Creates `public.notes` (demo table) - Enables strict per-user RLS policies on `public.notes` (RLS proof playground) Promote a user to admin (in SQL editor): ```sql update public.profiles set role = 'admin' where id = '<user-uuid>'; ``` ### 4) Run the app ```bash npm run dev ``` ## Deploying a public demo (Supabase Hosted + Vercel) If you want a public demo that supports real sign-in, you need: - A hosted Supabase project - A hosted Next.js deployment (Vercel recommended) ### 1) Create a Supabase project - Create a project in Supabase - Copy your project URL and publishable key ### 2) Apply migrations Run these in order (Supabase Dashboard SQL editor is fine): - `supabase/migrations/20251214190000_init.sql` - `supabase/migrations/20251216010600_notes.sql` ### 3) Configure Supabase Auth redirect URLs Add these redirect URLs in Supabase Auth settings: - `http://localhost:3000/auth/callback` - `http://localhost:3001/auth/callback` (optional if you use 3001 locally) - `https://YOUR_DEPLOY_DOMAIN/auth/callback` ### 4) Deploy to Vercel - Import the repo into Vercel (GitHub) - Set these environment variables: - `NEXT_PUBLIC_SUPABASE_URL` - `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` - `NEXT_PUBLIC_APP_URL=https://YOUR_DEPLOY_DOMAIN` ### 5) Promote an admin user (optional) ```sql update public.profiles set role = 'admin' where id = '<user-uuid>'; ``` ## Routes - `/` - Public landing page - `/about` - About page with features and benefits - `/why-use-magic-links` - Detailed explanation of passwordless authentication - `/sign-in` - Sign-in page (email magic link) - `/app` - Protected route (auth required) - `/admin` - Admin-only route (requires `profiles.role = 'admin'`) - `/lang?lang=<en|es>&next=<path>` - Language switcher ## Security Notes (Read This) - **RLS is enabled** on `public.profiles` by default. - **Do not disable RLS** to “make things work”. Fix policies instead. - This starter does not require a service role key. - If you add one later, **never expose it to the browser**. ## Project Structure ```text . ├─ app/ │ ├─ (marketing)/page.tsx │ ├─ (auth)/sign-in/ │ ├─ (auth)/auth/callback/ │ ├─ (auth)/auth/sign-out/ │ ├─ app/ (protected) │ └─ admin/ (admin-only) ├─ lib/ │ ├─ env.ts │ ├─ auth/ │ └─ supabase/ ├─ supabase/ │ ├─ migrations/ │ └─ config.toml ├─ middleware.ts └─ .github/workflows/ci.yml ``` ## Scripts - `npm run dev` - `npm run typecheck` - `npm run lint` - `npm run build` - `npm run start` ## License See `LICENSE`.
Explore similar templates
Compare previews and descriptions within the same stack and category.

Next.js SaaS Starter
The official Next.js SaaS starter template, integrating email/password authentication, Stripe Checkout subscriptions, a dashboard with user/team CRUD, basic Owner/Member RBAC, and activity logging.
Next.js · SaaS

Next.js Commerce
Vercel's officially maintained Next.js App Router ecommerce starter with deep Shopify integration, offering a complete product catalog, cart, and checkout flow. Core logic is modular for swapping backends, and community provider versions exist for BigCommerce, Medusa, and Saleor.
Next.js · E-commerce

Next-js-Boilerplate
A developer-first Next.js 16 starter with Tailwind CSS 4 and TypeScript, supporting both App Router and Page Router.
Next.js · Starter

tailwind-nextjs-starter-blog
A Next.js and Tailwind CSS blog starter template using Contentlayer for Markdown/MDX, with built-in SEO, code highlighting, and tags. It targets personal technical blogs and migration from Jekyll/Hugo to React, and supports one-click Vercel deployment.
Next.js · Blog

next-forge
next-forge is a Turborepo-based Next.js template maintained by Vercel, positioned as a starting point for SaaS products.
Next.js · Starter

SaaS-Boilerplate
SaaS-Boilerplate is an open-source SaaS starter template built with Next.js App Router, React 19, TypeScript, Tailwind CSS, and Shadcn UI.
Next.js · SaaS
