mirror of
https://github.com/supabase/supabase.git
synced 2026-06-22 04:52:48 +08:00
* 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>
26 lines
598 B
TypeScript
26 lines
598 B
TypeScript
import { createBrowserClient } from '@supabase/ssr'
|
|
import type { Database } from '@/utils/database.types'
|
|
import type { TypedSupabaseClient } from '@/utils/types'
|
|
import { useMemo } from 'react'
|
|
|
|
let client: TypedSupabaseClient | undefined
|
|
|
|
function getSupabaseBrowserClient() {
|
|
if (client) {
|
|
return client
|
|
}
|
|
|
|
client = createBrowserClient<Database>(
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!
|
|
)
|
|
|
|
return client
|
|
}
|
|
|
|
function useSupabaseBrowser() {
|
|
return useMemo(getSupabaseBrowserClient, [])
|
|
}
|
|
|
|
export default useSupabaseBrowser
|