stack-nextjs-supabase

Integrate Next.js App Router with Supabase using dual-client authentication and RLS policies.

25|7|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/xoai/sage --skill stack-nextjs-supabase
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stack-nextjs-supabase
Source: https://github.com/xoai/sage/tree/main/skills/stack-nextjs-supabase
Command: npx skills add https://github.com/xoai/sage --skill stack-nextjs-supabase

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and anti-patterns (resource) components.

What problem does it solve?

This Skill addresses critical integration gaps between Next.js App Router and Supabase, preventing common security vulnerabilities and ensuring robust authentication and data access.

Core Features & Use Cases

  • Secure Authentication: Implements correct browser/server client separation and middleware for token refresh.
  • Database Security: Enforces Row Level Security (RLS) policies and typed queries to protect your data.
  • Efficient Mutations: Leverages Server Actions for secure and type-safe data modifications.
  • Use Case: Building a SaaS application with Next.js and Supabase where user data must be strictly isolated and authentication must be seamless across server and client.

Quick Start

Integrate Next.js App Router with Supabase, ensuring secure authentication and data access.

Frequently Asked Questions about stack-nextjs-supabase

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

FAQPage Schema
How do I securely integrate Supabase authentication with the Next.js App Router?

Secure Supabase authentication with the Next.js App Router requires correct browser and server client separation alongside middleware for token refresh. This approach prevents common security vulnerabilities and ensures seamless user authentication across server and client environments.

What is the best way to enforce Row Level Security policies in a Next.js and Supabase SaaS application?

Enforcing Row Level Security (RLS) policies in a Next.js and Supabase SaaS application requires typed queries and strict client separation to protect your database. This configuration ensures user data remains strictly isolated and prevents unauthorized data exposure in production environments.

How do I use Server Actions for type-safe data mutations with Supabase in Next.js?

Using Server Actions for type-safe data mutations with Supabase in Next.js leverages server-side execution to securely modify your database records. This method enforces typed queries and secure authentication flows to prevent data exposure during operations.

Why does my Supabase authentication token refresh fail in Next.js middleware?

Supabase authentication token refresh fails in Next.js middleware when the dual-client separation is incorrectly implemented or anti-patterns are followed. Correctly configuring the middleware to handle token refresh ensures robust authentication and prevents session expiration issues.

Do I need separate Supabase clients for server and browser components in Next.js?

Yes, you need separate Supabase clients for server and browser components in Next.js to maintain secure authentication. Implementing correct dual-client separation ensures that tokens are handled appropriately across different environments, preventing unauthorized data access.

What are common security anti-patterns when connecting Next.js to Supabase?

Common security anti-patterns when connecting Next.js to Supabase include skipping Row Level Security policies, ignoring middleware token refresh, and failing to separate browser and server clients. Addressing these vulnerabilities ensures robust data isolation and secure authentication.