BeforeMerge

AI-native code review knowledge base. Structured rules that catch what linters miss.

Product

  • Features
  • Explore
  • Pricing
  • Docs
  • GitHub

Company

  • About
  • Blog
  • Contributors
  • Contributing

Legal

  • Privacy Policy
  • Terms of Service
  • MIT License

© 2026 BeforeMerge. Built by Peter Krzyzek

  1. Blog
  2. "Introducing the Next.js + Supabase Standards Library"
AnnouncementApril 9, 2026

"Introducing the Next.js + Supabase Standards Library"

"53 opinionated, production-proven rules and 12 in-depth guides for building full-stack Next.js + Supabase applications. Human-researched, not AI-generated."

Share

The Problem with "Best Practices"

Ask an AI assistant how to structure a Next.js + Supabase app and you'll get a different answer every time. Google it and you'll find contradictory advice across dozens of blog posts. Ask your team and you'll discover everyone has a slightly different approach.

There's no single, curated, stack-specific source of truth for "how should a modern Next.js + Supabase project be built?"

Until now.

What We're Launching

Today we're releasing the Next.js + Supabase Standards Library — 53 opinionated rules and 12 in-depth guides covering every layer of a full-stack Next.js + Supabase application.

Every rule is:

  • Researched from production codebases and official documentation
  • Opinionated — we made the decision so you don't have to
  • Enforceable — each rule maps to a detection pattern that BeforeMerge scans for automatically
  • Explained — good/bad code examples, impact ratings, and effort estimates

What's Covered

53 Rules Across 4 Categories

Category Rules Examples
Security 17 Enable RLS on every table, never expose service_role key, validate server action inputs
Architecture 7 Use route groups, keep server actions in dedicated files, use RLS helper functions
Quality 20 Handle Supabase errors explicitly, use error.tsx boundaries, structured logging
Performance 9 Server components by default, parallelize independent fetches, dynamic imports

12 Knowledge Guides

Deep-dive articles that explain the why behind the rules:

  • The Three Supabase Clients — when to use createClient() vs createAdminClient() vs createReadOnlyClient(), and why getting it wrong is a security vulnerability
  • RLS Policy Design Patterns — org-scoped access, public read with auth write, and the anti-patterns that cause data breaches
  • Server Components vs Client Components — the decision framework, with a flowchart and performance measurements
  • Server Action Patterns — the complete template: auth, validation, error handling, revalidation
  • Security Checklist — 25-point checklist covering env vars, RLS, SSRF, CSP, and more

Plus guides on data fetching, database migrations, auth flows, TypeScript patterns, testing, and performance optimization.

Why Not Just Use AI?

AI assistants are great for writing code. They're terrible at consistency. Ask Claude or ChatGPT the same architecture question twice and you'll get different answers. They don't know your team decided to use requireAuth() as the first call in every server action, or that your RLS policies all go through is_org_member().

These standards are the missing layer — the opinionated decisions your team makes once so AI and humans enforce them consistently.

When you install BeforeMerge standards, they're injected into every AI-generated suggestion. Instead of generic advice, you get recommendations that reference your standards.

Get Started in 3 Minutes

Option 1: Use with BeforeMerge (recommended)

  1. Sign up at beforemerge.com
  2. Install the GitHub App on your repo
  3. Go to Explore > find "Next.js + Supabase Standards"
  4. Click Install — rules are active in your next scan

Every PR gets scanned against all 53 rules. Violations show up as findings with AI-generated fix suggestions that reference your installed standards.

Option 2: Browse on GitHub

The rules and guides are open source across two repos:

  • Rules (for machines): github.com/BeforeMerge/beforemerge-skills — FSL-1.1-Apache-2.0
  • Guides (for humans): github.com/BeforeMerge/beforemerge-knowledge — CC BY-NC-SA 4.0

Browse, fork, adapt to your team. Contributions welcome via PR (CLA required for first-time contributors).

A Few Rules Worth Highlighting

The Supabase Query Builder Is Immutable

This is the #1 Supabase bug we see. The query builder returns a new object — calling .eq() without reassigning silently does nothing:

// BAD: filter silently ignored
let query = supabase.from("scans").select("*")
query.eq("status", "active")  // return value discarded!
const { data } = await query   // returns ALL scans
 
// GOOD: reassign the result
let query = supabase.from("scans").select("*")
query = query.eq("status", "active")
const { data } = await query   // returns only active scans

Never Use the Admin Client for Reads

createAdminClient() bypasses all RLS policies. Using it for SELECT queries removes your safety net — a missing WHERE clause returns data from every organization:

// BAD: bypasses RLS, sees all orgs
const admin = createAdminClient()
const { data } = await admin.from("scans").select("*")
 
// GOOD: RLS enforced, only sees user's org
const supabase = await createClient()
const { data } = await supabase.from("scans").select("*")

Call auth.getUser() Immediately in Middleware

This one comes straight from the Supabase docs: "Do not run code between createServerClient and supabase.auth.getUser()." Violating this causes users to be randomly logged out with no clear cause. We've seen it happen.

What's Next

This is the first standards collection — focused on our own stack (Next.js + Supabase). Coming next:

  • TypeScript Standards — strict mode patterns, generics, discriminated unions
  • React Standards — hooks patterns, state management, rendering optimization
  • Git & CI/CD Standards — commit conventions, branch strategies, CI requirements

We're also working on Convention Detection — BeforeMerge will analyze your codebase, detect your existing patterns, and propose them as enforceable rules. Your conventions, automatically documented and enforced.

Try It

  • Install on your repo: beforemerge.com
  • Browse rules: beforemerge-skills on GitHub
  • Read guides: beforemerge-knowledge on GitHub

Standards shouldn't live in someone's head. They should be written down, enforced automatically, and improved over time. That's what BeforeMerge does.

standardsnextjssupabaseopen-sourcelaunch

Comments

On this page

  • The Problem with "Best Practices"
  • What We're Launching
  • What's Covered
  • 53 Rules Across 4 Categories
  • 12 Knowledge Guides
  • Why Not Just Use AI?
  • Get Started in 3 Minutes
  • Option 1: Use with BeforeMerge (recommended)
  • Option 2: Browse on GitHub
  • A Few Rules Worth Highlighting
  • The Supabase Query Builder Is Immutable
  • Never Use the Admin Client for Reads
  • Call auth.getUser() Immediately in Middleware
  • What's Next
  • Try It
BeforeMerge
Features
Explore
PricingBlogContributorsInstall Guide
2Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsInstall Guide
Sign In