mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 11:55:05 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated examples and guides to use Supabase publishable (client) keys instead of anon keys for client-side usage across frameworks and platforms. * Renamed environment variable examples and .env templates to reflect publishable key naming. * Adjusted sample requests and client-init examples to send/use the publishable key via the apikey header where applicable. * Updated references from service_role to secret for server-side credential guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: fadymak <fady@fadymak.com>
35 lines
904 B
TypeScript
35 lines
904 B
TypeScript
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
import { createClient } from '@supabase/supabase-js'
|
|
import 'react-native-url-polyfill/auto'
|
|
|
|
const isSSR = typeof window === 'undefined'
|
|
|
|
const ExpoWebSecureStoreAdapter = {
|
|
getItem: (key: string) => {
|
|
if (isSSR) return null
|
|
console.debug('getItem', { key })
|
|
return AsyncStorage.getItem(key)
|
|
},
|
|
setItem: (key: string, value: string) => {
|
|
if (isSSR) return
|
|
return AsyncStorage.setItem(key, value)
|
|
},
|
|
removeItem: (key: string) => {
|
|
if (isSSR) return
|
|
return AsyncStorage.removeItem(key)
|
|
},
|
|
}
|
|
|
|
export const supabase = createClient(
|
|
process.env.EXPO_PUBLIC_SUPABASE_URL ?? '',
|
|
process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY ?? '',
|
|
{
|
|
auth: {
|
|
storage: ExpoWebSecureStoreAdapter,
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: false,
|
|
},
|
|
}
|
|
)
|