Communitygithub.com

Anhvu1107/all-agent-skill

Verwende dies IMMER, wenn die Anfrage Next.js Supabase Auth betrifft: Expertenintegration von Supabase Auth mit dem Next.js App Router.

Was ist all-agent-skill?

Diese Fähigkeit bietet eine umfassende Expertenintegration von Supabase Auth mit dem Next.js App Router. Sie umfasst die Erstellung korrekt konfigurierter Supabase-Clients für Browser- und Serverkontexte, Middleware für Routenschutz und Sitzungserneuerung, OAuth-Callback-Routen, Server Action Auth sowie die Anzeige authentifizierter Benutzer in Server Components. Die Fähigkeit validiert gängige Fallstricke wie die Verwendung von getSession() anstelle von getUser() oder fehlende Middleware. Sie delegiert verwandte Aufgaben wie Datenbank-Setup oder UI-Komponenten an andere spezialisierte Fähigkeiten und gliedert sich in einen vollständigen Authentifizierungs-Workflow mit Datenbank, Routenschutz und Deployment. Ideal für Entwickler, die eine sichere, produktionsreife Supabase Auth-Integration in Next.js-Anwendungen benötigen.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Anhvu1107/all-agent-skill/tree/HEAD/.agent/skills/nextjs-supabase-auth

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Next.js + Supabase Auth

Regel für selektives Lesen

Beginne mit:

  • references/senior-master-standard.md
  • references/usage-routing.md
  • references/quality-checklist.md

Lade dann nur die geerbten Dokumente, Skripte, Assets oder Beispiele, die zur tatsächlichen Aufgabe des Benutzers passen.

Expertenintegration von Supabase Auth mit dem Next.js App Router

Fähigkeiten

  • nextjs-auth
  • supabase-auth-nextjs
  • auth-middleware
  • auth-callback

Voraussetzungen

  • Erforderliche Fähigkeiten: nextjs-app-router, supabase-backend

Patterns

Supabase-Client-Setup

Erstelle korrekt konfigurierte Supabase-Clients für verschiedene Kontexte

Wann verwenden: Einrichtung von Auth in einem Next.js-Projekt

// lib/supabase/client.ts (Browser-Client)
'use client'
import { createBrowserClient } from '@supabase/ssr'

export function createClient() {
  return createBrowserClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
  )
}

// lib/supabase/server.ts (Server-Client)
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'

export async function createClient() {
  const cookieStore = await cookies()
  return createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
      cookies: {
        getAll() {
          return cookieStore.getAll()
        },
        setAll(cookiesToSet) {
          cookiesToSet.forEach(({ name, value, options }) => {
            cookieStore.set(name, value, options)
          })
        },
      },
    }
  )
}

Auth-Middleware

Schütze Routen und erneuere Sitzungen in der Middleware

Wann verwenden: Du benötigst Routenschutz oder Sitzungserneuerung

// middleware.ts
import { createServerClient } from '@supabase/ssr'
import { NextResponse, type NextRequest } from 'next/server'

export async function middleware(request: NextRequest) {
  let response = NextResponse.next({ request })

  const supabase = createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
      cookies: {
        getAll() {
          return request.cookies.getAll()
        },
        setAll(cookiesToSet) {
          cookiesToSet.forEach(({ name, value, options }) => {
            response.cookies.set(name, value, options)
          })
        },
      },
    }
  )

  // Sitzung erneuern, falls abgelaufen
  const { data: { user } } = await supabase.auth.getUser()

  // Dashboard-Routen schützen
  if (request.nextUrl.pathname.startsWith('/dashboard') && !user) {
    return NextResponse.redirect(new URL('/login', request.url))
  }

  return response
}

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}

Auth-Callback-Route

Behandle OAuth-Callback und tausche Code gegen Sitzung aus

Wann verwenden: Verwendung von OAuth-Anbietern (Google, GitHub, etc.)

// app/auth/callback/route.ts
import { createClient } from '@/lib/supabase/server'
import { NextResponse } from 'next/server'

export async function GET(request: Request) {
  const { searchParams, origin } = new URL(request.url)
  const code = searchParams.get('code')
  const next = searchParams.get('next') ?? '/'

  if (code) {
    const supabase = await createClient()
    const { error } = await supabase.auth.exchangeCodeForSession(code)
    if (!error) {
      return NextResponse.redirect(`${origin}${next}`)
    }
  }

  return NextResponse.redirect(`${origin}/auth/error`)
}

Server Action Auth

Führe Auth-Operationen in Server Actions durch

Wann verwenden: Login, Logout oder Signup von Server Components

// app/actions/auth.ts
'use server'
import { createClient } from '@/lib/supabase/server'
import { redirect } from 'next/navigation'
import { revalidatePath } from 'next/cache'

export async function signIn(formData: FormData) {
  const supabase = await createClient()
  const { error } = await supabase.auth.signInWithPassword({
    email: formData.get('email') as string,
    password: formData.get('password') as string,
  })

  if (error) {
    return { error: error.message }
  }

  revalidatePath('/', 'layout')
  redirect('/dashboard')
}

export async function signOut() {
  const supabase = await createClient()
  await supabase.auth.signOut()
  revalidatePath('/', 'layout')
  redirect('/')
}

Benutzer in Server Component abrufen

Greife in Server Components auf den authentifizierten Benutzer zu

Wann verwenden: Serverseitiges Rendern von benutzerspezifischen Inhalten

// app/dashboard/page.tsx
import { createClient } from '@/lib/supabase/server'
import { redirect } from 'next/navigation'

export default async function DashboardPage() {
  const supabase = await createClient()
  const { data: { user } } = await supabase.auth.getUser()

  if (!user) {
    redirect('/login')
  }

  return (
    <div>
      <h1>Willkommen, {user.email}</h1>
    </div>
  )
}

Validierungsprüfungen

Verwendung von getSession() für Auth-Prüfungen

Schweregrad: FEHLER

Nachricht: getSession() überprüft das JWT nicht. Verwende getUser() für sichere Auth-Prüfungen.

Behebungsaktion: Ersetze getSession() durch getUser() für sicherheitskritische Prüfungen.

OAuth ohne Callback-Route

Schweregrad: FEHLER

Nachricht: OAuth verwendet, aber Callback-Route unter app/auth/callback/route.ts fehlt.

Behebungsaktion: Erstelle app/auth/callback/route.ts, um OAuth-Weiterleitungen zu behandeln.

Browser-Client im Server-Kontext

Schweregrad: FEHLER

Nachricht: Browser-Client im Server-Kontext verwendet. Verwende stattdessen createServerClient.

Behebungsaktion: Importiere und verwende createServerClient von @supabase/ssr.

Geschützte Routen ohne Middleware

Schweregrad: WARNUNG

Nachricht: Keine middleware.ts gefunden. Erwäge das Hinzufügen einer Middleware für den Routenschutz.

Behebungsaktion: Erstelle middleware.ts, um Routen zu schützen und Sitzungen zu erneuern.

Hartcodierte Auth-Weiterleitungs-URL

Schweregrad: WARNUNG

Nachricht: Hartcodierte localhost-Weiterleitung. Verwende origin für Umgebungsflexibilität.

Behebungsaktion: Verwende window.location.origin oder process.env.NEXT_PUBLIC_SITE_URL.

Auth-Aufruf ohne Fehlerbehandlung

Schweregrad: WARNUNG

Nachricht: Auth-Operation ohne Fehlerbehandlung. Überprüfe immer auf Fehler.

Behebungsaktion: Destrukturiere { data, error } und behandle den Fehlerfall.

Auth-Aktion ohne Revalidierung

Schweregrad: WARNUNG

Nachricht: Auth-Aktion ohne revalidatePath. Cache könnte veralteten Auth-Status anzeigen.

Behebungsaktion: Füge revalidatePath('/', 'layout') nach Auth-Operationen hinzu.

Client-seitiger Routenschutz

Schweregrad: WARNUNG

Nachricht: Client-seitiger Routenschutz zeigt Inhaltsblitz. Verwende Middleware.

Behebungsaktion: Verschiebe den Schutz in middleware.ts für bessere UX.

Zusammenarbeit

Delegierungsauslöser

  • database|rls|queries|tables -> supabase-backend (Auth benötigt Datenbankebene)
  • route|page|component|layout -> nextjs-app-router (Auth benötigt Next.js Patterns)
  • deploy|production|vercel -> vercel-deployment (Auth benötigt Deployment-Konfiguration)
  • ui|form|button|design -> frontend (Auth benötigt UI-Komponenten)

Vollständiger Auth-Stack

Fähigkeiten: nextjs-supabase-auth, supabase-backend, nextjs-app-router, vercel-deployment

Workflow:

1. Datenbank-Setup (supabase-backend)
2. Auth-Implementierung (nextjs-supabase-auth)
3. Routenschutz (nextjs-app-router)
4. Deployment-Konfiguration (vercel-deployment)

Geschützte SaaS

Fähigkeiten: nextjs-supabase-auth, stripe-integration, supabase-backend

Workflow:

1. Benutzerauthentifizierung (nextjs-supabase-auth)
2. Kundensynchronisierung (stripe-integration)
3. Abonnement-Gating (supabase-backend)

Verwandte Fähigkeiten

Funktioniert gut mit: nextjs-app-router, supabase-backend

Wann verwenden

  • Benutzer erwähnt oder impliziert: supabase auth next
  • Benutzer erwähnt oder impliziert: authentication next.js
  • Benutzer erwähnt oder impliziert: login supabase
  • Benutzer erwähnt oder impliziert: auth middleware
  • Benutzer erwähnt oder impliziert: protected route
  • Benutzer erwähnt oder impliziert: auth callback
  • Benutzer erwähnt oder impliziert: session management

Einschränkungen

  • Verwende diese Fähigkeit nur, wenn die Aufgabe eindeutig dem oben beschriebenen Umfang entspricht.
  • Betrachte die Ausgabe nicht als Ersatz für umgebungsspezifische Validierung, Tests oder Expertenüberprüfung.
  • Halte inne und frage nach Klärung, wenn erforderliche Eingaben, Berechtigungen, Sicherheitsgrenzen oder Erfolgskriterien fehlen.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches 007: Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Agentfolio: Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Animejs Animation: Advanced JavaScript animation library skill for creating complex, high-performance web animations.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astropy: Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astro: Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Emotional ARC Designer: One sentence - what this skill does and when to invoke it

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Fixing Motion Performance: Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches I18n Localization: Internationalization and localization patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Interactive Portfolio: Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches JQ: Expert jq usage for JSON querying, filtering, transformation, and pipeline integration.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Landing Page Generator: Generates high-converting Next.js/React landing pages with Tailwind CSS.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches LEX: Centralized ''Truth Engine'' for cross-jurisdictional legal context (US, EU, CA) and contract scaffolding.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Magic Animator: AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Makepad Animation: CRITICAL: Use for Makepad animation system.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs APP Router Patterns: Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

Anhvu1107/all-agent-skill

ALWAYS use this when the user mentions Nextjs Best Practices, asks to build, debug, review, document, automate, test, configure, migrate, or make decisions in this domain, or the task clearly depends on Nextjs Best Practices; scope: Next.js App Router principles. Apply the bundled workflow, references, scripts, Senior Master standard, and Codex strict review gate before final output.

Anhvu1107/all-agent-skill

description: ALWAYS use this when the work is specifically about modern Next.js or React architecture, data flow, rendering strategy, routing, or performance-sensitive frontend behavior.

Anhvu1107/all-agent-skill

ALWAYS use this when the task involves reading, extracting, splitting, merging, rotating, creating, validating, OCR-ing, form-filling, or otherwise producing or modifying PDF files.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches React Nextjs Development: React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when working with Remotion code, video compositions, rendering logic, timing, media assets, or React-based motion workflows.

Verwandte Skills