Files
supabase/examples/clerk/hooks/useSupabaseClient.ts
Stojan Dimitrovski 93ba2a312c docs: indicate publishable key instead of anon in many examples (#37411)
* 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>
2025-08-18 13:47:48 +02:00

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
}