nextjs-supabase-ssr

Configure Supabase clients for Next.js 15 App Router authentication contexts.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/Ritenoob/ridedine --skill nextjs-supabase-ssr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-supabase-ssr
Source: https://github.com/Ritenoob/ridedine/tree/main/.claude/skills/nextjs-supabase-ssr
Command: npx skills add https://github.com/Ritenoob/ridedine --skill nextjs-supabase-ssr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the complexity of managing Supabase authentication securely and efficiently within Next.js 15's App Router, ensuring proper cookie handling across different rendering contexts (Server Components, Server Actions, Client Components, Route Handlers).

Core Features & Use Cases

  • Context-Specific Supabase Clients: Provides distinct factory functions for creating Supabase clients tailored to Server Components (read-only cookies), Server Actions (read-write cookies), Route Handlers, and Client Components.
  • SSR Auth Implementation: Guides on implementing server-side authentication, protecting routes with middleware, and handling auth state changes.
  • Debugging Common Issues: Offers solutions for "user is undefined" errors, cookie persistence problems, middleware redirect loops, and real-time subscription failures.
  • Use Case: When building a Next.js application that uses Supabase for user authentication, you need to ensure that user sessions are correctly managed whether data is fetched on the server or client. This Skill provides the exact patterns to achieve this, preventing common security and functionality bugs.

Quick Start

Use the nextjs-supabase-ssr skill to create a Supabase client for server components in your Next.js application.

Frequently Asked Questions about nextjs-supabase-ssr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Supabase authentication in Next.js App Router for server-side rendering?

To configure Supabase authentication in Next.js App Router for server-side rendering, use distinct factory functions to create context-specific Supabase clients for Server Components, Server Actions, Route Handlers, and Client Components. This ensures correct HTTP-only cookie handling for session persistence across all rendering contexts.

Why does the Supabase user return undefined in my Next.js Server Components?

The Supabase user returns undefined in Next.js Server Components when using a client-side Supabase instance instead of a server-side one. You must create a Supabase client configured to read HTTP-only cookies within the Server Component to properly access the authentication state.

How do I protect routes with Supabase and Next.js middleware without causing redirect loops?

To protect routes with Supabase and Next.js middleware without causing redirect loops, ensure your middleware correctly refreshes the authentication session and only redirects unauthenticated users from protected paths. Properly managing cookie updates in middleware prevents infinite redirect cycles common in SSR setups.

Do I need different Supabase clients for Server Actions and Route Handlers in Next.js 15?

Yes, you need different Supabase clients for Server Actions and Route Handlers in Next.js 15. Server Actions require a client configured for read-write cookie manipulation to update sessions, while Route Handlers and Server Components need specific client configurations to correctly manage HTTP-only cookies securely.

What is the best way to handle Supabase auth state changes and real-time subscriptions in Next.js SSR?

The best way to handle Supabase auth state changes and real-time subscriptions in Next.js SSR is using a Client Component Supabase client. This dedicated client correctly manages browser-side auth state and resolves common real-time subscription failures caused by misconfigured server-side cookie contexts.