-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase.ts
More file actions
18 lines (15 loc) · 1.15 KB
/
Copy pathsupabase.ts
File metadata and controls
18 lines (15 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { createClientComponentClient, createServerComponentClient, createServerActionClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import type { Database } from '@/types/database'
// ─── Browser / Client Components ─────────────────────────────────────────────
// Use this in any 'use client' component
export const createClient = () =>
createClientComponentClient<Database>()
// ─── Server Components ────────────────────────────────────────────────────────
// Use this in Server Components (no 'use client')
export const createServerClient = () =>
createServerComponentClient<Database>({ cookies })
// ─── Server Actions & Route Handlers ─────────────────────────────────────────
// Use this inside server actions or API route handlers
export const createActionClient = () =>
createServerActionClient<Database>({ cookies })