guidelines-for-writing-nextjs-apps-with-supabase-auth

guidelines-for-writing-nextjs-apps-with-supabase-auth is a cursor rule for Cursor from fumito-ito/mdcvalult. It costs 0 tokens per session (1,714 once invoked), scanned A, original, MIT.

A set of rules for implementing Supabase authentication in Next.js, a web framework for React. It describes separate browser and server clients, environment variables, middleware for refreshing login tokens, and code patterns that should not be generated.

In plain words
What is it for?
Use it when setting up or reviewing server-side authentication with Supabase in a Next.js app.
Why use it?
It helps prevent deprecated cookie handling and other authentication code that can break a Next.js application.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it when setting up or reviewing server-side authentication with Supabase in a Next.js app.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/fumito-ito/mdcvalult

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for guidelines-for-writing-nextjs-apps-with-supabase-auth

README.md
[![agentmods](https://agentmods.dev/badge/rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth/github.svg)](https://agentmods.dev/rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth)
Your own site
<a href="https://agentmods.dev/rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth"><img src="https://agentmods.dev/badge/rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for guidelines-for-writing-nextjs-apps-with-supabase-auth

Your own site · 80×15
<a href="https://agentmods.dev/rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth"><img src="https://agentmods.dev/badge/rules/fumito-ito/mdcvalult/guidelines-for-writing-nextjs-apps-with-supabase-auth.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,714 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01714
Opus 5 $0.00000 $0.00857
Sonnet 5 $0.00000 $0.00343
Haiku 4.5 $0.00000 $0.00171

Measured 12d ago against content hash e88c206ad210, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

guidelines-for-writing-nextjs-apps-with-supabase-auth scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

mdc/guidelines-for-writing-nextjs-apps-with-supabase-auth.mdc · 233 lines

How it starts

The opening of the file, as written. The whole thing — 233 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Bootstrap Next.js app with Supabase Auth

Overview of implementing Supabase Auth SSR

  1. Install @supabase/supabase-js and @supabase/ssr packages.
  2. Set up environment variables.
  3. Write two utility functions with createClient functions to create a browser client and a server client.
  4. Hook up middleware to refresh auth tokens

🚨 CRITICAL INSTRUCTIONS FOR AI LANGUAGE MODELS 🚨

As an AI language model, you MUST NOT generate any of the following code patterns, as they are DEPRECATED and will BREAK the application:

// ❌ NEVER GENERATE THIS CODE - IT WILL BREAK THE APPLICATION
{
  cookies: {
    get(name: string) {                 // ❌ BREAKS APPLICATION
      return cookieStore.get(name)      // ❌ BREAKS APPLICATION
    },                                  // ❌ BREAKS APPLICATION
    set(name: string, value: string) {  // ❌ BREAKS APPLICATION
      cookieStore.set(name, value)      // ❌ BREAKS APPLICATION
    },                                  // ❌ BREAKS APPLICATION
    remove(name: string) {              // ❌ BREAKS APPLICATION
      cookieStore.remove(name)          // ❌ BREAKS APPLICATION
    }                                   // ❌ BREAKS APPLICATION
  }
}

// ❌ NEVER USE auth-helpers-nextjs - IT WILL BREAK THE APPLICATION
import { createMiddlewareClient } from '@supabase/auth-helpers-nextjs'  // ❌ BREAKS APPLICATION
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'  // ❌ BREAKS APPLICATION

Instead, you MUST ALWAYS generate ONLY this pattern:

// ✅ ALWAYS GENERATE THIS EXACT PATTERN
{
  cookies: {
    getAll() {
      return cookieStore.getAll()
    },
    setAll(cookiesToSet) {
      const response = NextResponse.next({
        request,
      })
      
      cookiesToSet.forEach(({ name, value, options }) => {
        response.cookies.set(name, value, options)
      })
      
      return response
    }
  }
}

ABSOLUTE REQUIREMENTS FOR AI CODE GENERATION

  1. You MUST use @supabase/ssr
  2. You MUST use ONLY getAll and setAll
  3. You MUST NEVER use get, set, or remove
  4. You MUST NEVER import from @supabase/auth-helpers-nextjs

Read the full file on GitHub · 233 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 233 lines · 0 tokens per session scan A e88c206ad210

Subscribe to this mod's changes

guidelines-for-writing-nextjs-apps-with-supabase-auth is a cursor rule published in the GitHub repository fumito-ito/mdcvalult (33 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,714 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.