mirror of
https://github.com/supabase/supabase.git
synced 2026-07-07 11:40:20 +08:00
* feat(blog): Add React Query post. * feat(examples): Add React Query example. * Apply suggestions from code review Thank you 💚 Co-authored-by: Philipp Steinrötter <philipp@steinroetter.com> * chore: update og image. --------- Co-authored-by: Philipp Steinrötter <philipp@steinroetter.com>
26 lines
591 B
TypeScript
26 lines
591 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_ANON_KEY!
|
|
)
|
|
|
|
return client
|
|
}
|
|
|
|
function useSupabaseBrowser() {
|
|
return useMemo(getSupabaseBrowserClient, [])
|
|
}
|
|
|
|
export default useSupabaseBrowser
|