Skip to content

Latest commit

Β 

History

60 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” React Supabase Auth Starter

A production-ready authentication template built with React 19 + TypeScript + Supabase, following Staff Engineer standards. Secure auth flows, i18n, comprehensive testing, automated CI/CD with security auditing, and enforced code quality β€” ready to deploy in minutes.

Live Demo License: MIT CI Pipeline React TypeScript Supabase

Deploy with Vercel


🎯 What is This?

This is not just another auth boilerplate. It's a complete foundation for production web apps, designed with the same standards used at companies like Google, Meta, and Stripe. Every decision β€” from folder structure to CI pipeline β€” follows Staff Engineer-level practices documented in 3000+ lines of coding standards.

πŸš€ Live Demo: https://react-supabase-auth-starter.vercel.app/

πŸ“Έ Screenshots

Home Page Login Modal Signup Modal
Home Page Login Modal Signup Modal
Forgot Password Dashboard - Profile Dashboard - Settings
Forgot Password Dashboard Profile Dashboard Settings
Language Switcher Home (Light On) Info Page
Language Switcher Home Active Info Page

✨ Key Features

πŸ” Complete Authentication System

  • βœ… Email/Password login with real-time validation
  • βœ… Google OAuth integration (extensible to GitHub, Apple, etc.)
  • βœ… Password reset flow with email recovery
  • βœ… Account creation with email verification
  • βœ… Change email, change password, delete account
  • βœ… Protected routes with Zustand state management
  • βœ… Session persistence and automatic token refresh
  • βœ… Client-side rate limiter with exponential backoff

🎨 Modern UI/UX

  • βœ… Clean, responsive design with Tailwind CSS v4
  • βœ… Smooth animations (animated tabs, modal transitions)
  • βœ… Interactive home page (light switch, rain, wind effects)
  • βœ… Password strength indicator with visual feedback
  • βœ… Loading states, error handling, and confirmation modals

🌍 Internationalization (i18n)

  • βœ… Full English and Spanish support
  • βœ… Easy to add new languages (JSON-based)
  • βœ… Persistent language selection (localStorage)
  • βœ… Real-time translation without page reload

πŸ”’ Security (Staff Engineer Level)

  • βœ… TypeScript strict mode β€” zero implicit any
  • βœ… Input sanitization and validation (email, password strength)
  • βœ… Client-side rate limiter with exponential backoff (brute-force protection)
  • βœ… Security headers via Vercel (CSP, HSTS, X-Frame-Options, Referrer-Policy)
  • βœ… RLS (Row Level Security) policies on Supabase
  • βœ… Environment variables for all secrets (zero hardcoded keys)
  • βœ… Automated vulnerability scanning (audit-ci in CI pipeline)
  • βœ… Dependabot for weekly dependency updates
  • βœ… SECURITY.md with vulnerability reporting process

πŸ§ͺ Comprehensive Testing

  • βœ… Unit tests β€” Vitest + Testing Library (utils, hooks, components)
  • βœ… E2E tests β€” Playwright across 3 browsers (Chromium, Firefox, WebKit)
  • βœ… Test coverage reporting with @vitest/coverage-v8
  • βœ… Dedicated test fixtures and helpers

πŸš€ CI/CD & DevOps

  • βœ… GitHub Actions β€” Lint β†’ Test β†’ Build β†’ Security Audit (every PR)
  • βœ… Playwright CI β€” E2E tests in 3 browsers with artifact uploads
  • βœ… Dependency caching β€” 85% faster CI builds
  • βœ… Branch protection β€” PR required, code owner review, status checks
  • βœ… CODEOWNERS β€” Automatic review assignment for critical paths
  • βœ… PR Template β€” Standardized PR descriptions with security checklist
  • βœ… Dependabot β€” Automated weekly dependency scanning
  • βœ… Vercel deployment β€” Automatic preview deploys on PRs

πŸ“– Professional Documentation

  • βœ… AGENTS.md β€” 3000+ lines of coding standards (Security, Architecture, Testing, CI/CD, Performance)
  • βœ… PROJECT_STRUCTURE.md β€” File organization guide with migration paths
  • βœ… SECURITY.md β€” Vulnerability reporting and security practices
  • βœ… CONTRIBUTING.md β€” Contribution guidelines and PR standards
  • βœ… JSDoc comments β€” All exported functions documented
  • βœ… Inline comments β€” Code explains "why", not just "what"

πŸ›  Tech Stack

Category Technologies
Frontend React 19, TypeScript 5.9, Vite 7, SWC
Styling Tailwind CSS v4 (via Vite plugin)
State Zustand 5 (auth + UI stores)
Backend/Auth Supabase (Auth, PostgreSQL, RLS, Edge Functions)
Runtime Bun (package manager + task runner)
Unit Testing Vitest, Testing Library, jsdom
E2E Testing Playwright (Chromium, Firefox, WebKit)
CI/CD GitHub Actions (lint, test, build, audit)
Deployment Vercel (with security headers)
Code Quality ESLint, Prettier, Husky, lint-staged
Security audit-ci, Dependabot, CODEOWNERS, branch protection
i18n react-i18next, i18next

πŸš€ Quick Start

Prerequisites

  • Bun (recommended) or Node.js 18+
  • Supabase account (free tier available)

Installation

# Clone the repository
git clone https://github.com/jjmendezrodriguez/react-supabase-auth-starter.git
cd react-supabase-auth-starter

# Navigate to frontend
cd frontEnd

# Install dependencies
bun install

# Set up environment variables
cp .env.example .env
# Edit .env with your Supabase credentials

# Start development server
bun dev

Visit http://localhost:5174 πŸŽ‰


πŸ“ Project Structure

frontEnd/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication modals
β”‚   β”‚   └── dashboard/      # User dashboard
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”œβ”€β”€ services/           # External integrations
β”‚   β”‚   └── supabase/       # Supabase client
β”‚   β”œβ”€β”€ stores/             # Zustand state stores
β”‚   β”œβ”€β”€ utils/              # Pure utility functions
β”‚   β”œβ”€β”€ pages/              # Route pages
β”‚   └── locales/            # i18n translations
β”œβ”€β”€ e2e/                    # Playwright E2E tests
β”œβ”€β”€ test/                   # Vitest unit tests
β”œβ”€β”€ docs/                   # Documentation
└── .github/workflows/      # CI/CD pipelines

See PROJECT_STRUCTURE.md for detailed organization.


πŸ“š Documentation

This project is thoroughly documented β€” not just code comments, but full engineering guides:

Document Purpose
AGENTS.md 3000+ lines of coding standards β€” security, architecture, testing, CI/CD, performance, scalability
PROJECT_STRUCTURE.md File organization guide with Type-based β†’ Feature-based migration path
SECURITY.md Security practices, vulnerability reporting, and incident response
CONTRIBUTING.md Contribution guidelines, PR standards, and code review process
E2E_TESTING_GUIDE.md Playwright E2E testing guide with patterns and best practices
Frontend README Detailed frontend architecture, Supabase setup, and component docs

πŸ’‘ Why This Template?

Most auth templates give you a login form and call it done. This one gives you the full engineering foundation:

❌ Typical auth template:           βœ… This template:
─────────────────────────          ─────────────────────────
Login form                         Complete auth system (7 flows)
No tests                           Unit + E2E tests (3 browsers)
No CI/CD                           GitHub Actions pipeline (4 stages)
No security                        Rate limiting, CSP, HSTS, audit-ci
No docs                            3000+ lines of engineering standards
"Works on my machine"              Vercel deploy in 2 minutes

Time saved: ~3-4 weeks of setup and security hardening for every new project.


πŸ§ͺ Available Scripts

# Development
bun dev              # Start development server
bun build            # Build for production
bun lint             # Run ESLint
bun preview          # Preview production build

# Unit Tests (Vitest)
bun test             # Run tests in watch mode
bun test:run         # Run tests once
bun test:coverage    # Generate coverage report
bun test:ui          # Open Vitest UI

# E2E Tests (Playwright)
bun test:e2e         # Run all E2E tests
bun test:e2e:headed  # Run with visible browser
bun test:e2e:ui      # Open Playwright UI
bun test:e2e:debug   # Debug mode
bun test:e2e:report  # View last HTML report
bun test:e2e:codegen # Record new tests

πŸ”§ Environment Setup

Create a .env file in frontEnd/ (or copy the example):

cp frontEnd/.env.example frontEnd/.env
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key

Get your Supabase credentials from: Supabase Dashboard β†’ Settings β†’ API


πŸ—„οΈ Database Setup

1. Create profiles table

CREATE TABLE profiles (
  id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE,
  first_name TEXT,
  last_name TEXT,
  email TEXT,
  avatar_url TEXT,
  bio TEXT,
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW()
);

2. Enable Row Level Security (RLS)

ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;

-- Users can view their own profile
CREATE POLICY "Users can view own profile"
  ON profiles FOR SELECT
  USING (auth.uid() = id);

-- Users can update their own profile
CREATE POLICY "Users can update own profile"
  ON profiles FOR UPDATE
  USING (auth.uid() = id);

-- Users can insert their own profile
CREATE POLICY "Users can insert own profile"
  ON profiles FOR INSERT
  WITH CHECK (auth.uid() = id);

3. Create Database Triggers

These triggers keep profiles in sync with Supabase Auth:

  • on_auth_user_created β€” Auto-creates a profile row when a new user signs up
  • on_auth_user_email_updated β€” Syncs email changes from auth to profiles
  • on_profile_name_updated β€” Syncs name changes from profiles to auth.users metadata

4. Deploy Edge Function (optional)

The delete-user Edge Function handles privileged account deletion:

supabase functions deploy delete-user

See: frontEnd/README.md for detailed SQL and trigger definitions.


πŸ“§ Email Templates

Supabase sends automatic emails for authentication events. To customize them:

  1. Go to Supabase Dashboard β†’ Authentication β†’ Email Templates

  2. Edit these templates to match your brand:

    Template When it's sent
    Confirm signup After user creates an account
    Reset password When user requests password recovery
    Magic link When using passwordless login
    Change email When user updates their email address
    Invite user When you invite users via dashboard
  3. (Optional) Configure custom SMTP for branded email delivery under Project Settings β†’ Auth β†’ SMTP Settings

Docs: Supabase Email Templates Β· Custom SMTP


🀝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and development process.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Jose Mendez β€” Software Engineer
Building production-grade tools with Staff Engineer standards.

πŸ’Ό LinkedIn Β· πŸ™ GitHub


🌟 Show Your Support

If this template saved you time or taught you something, give it a ⭐️ on GitHub!

Found a bug? Open an issue Β· Want to contribute? Read CONTRIBUTING.md

About

Production-ready auth template: React 19 + TypeScript + Supabase. Email/OAuth login, protected routes, i18n (EN/ES), Zustand state, rate limiting. Vitest + Playwright E2E testing, CI/CD with security auditing, Vercel deployment. Staff Engineer standards with enforced code quality. MIT Licensed.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages