mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 01:10:15 -04:00
93ba2a312c
* docs: indicate publishable key instead of anon in many examples * replace your-anon-key to string indicating publishable or anon * fix your_... * apply suggestion from @ChrisChinchilla Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com> * Update keys in code examples * Prettier fix * Update apps/docs/content/guides/functions/schedule-functions.mdx --------- Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
17 lines
527 B
TypeScript
17 lines
527 B
TypeScript
import { useSession } from '@clerk/nextjs'
|
|
import { createClient } from '@supabase/supabase-js'
|
|
|
|
export function useSupabaseClient() {
|
|
const { session } = useSession()
|
|
const supabaseClient = createClient(
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
|
|
{
|
|
// Session accessed from Clerk SDK, either as Clerk.session (vanilla
|
|
// JavaScript) or useSession (React)
|
|
accessToken: async () => session?.getToken() ?? null,
|
|
}
|
|
)
|
|
return supabaseClient
|
|
}
|