mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 08:56:46 -04:00
d8bd6b047c
## 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>
34 lines
979 B
TypeScript
34 lines
979 B
TypeScript
import { createClient } from '@supabase/supabase-js'
|
|
import { deleteItemAsync, getItemAsync, setItemAsync } from 'expo-secure-store'
|
|
|
|
const ExpoSecureStoreAdapter = {
|
|
getItem: (key: string) => {
|
|
console.debug('getItem', { key, getItemAsync })
|
|
return getItemAsync(key)
|
|
},
|
|
setItem: (key: string, value: string) => {
|
|
if (value.length > 2048) {
|
|
console.warn(
|
|
'Value being stored in SecureStore is larger than 2048 bytes and it may not be stored successfully. In a future SDK version, this call may throw an error.'
|
|
)
|
|
}
|
|
return setItemAsync(key, value)
|
|
},
|
|
removeItem: (key: string) => {
|
|
return deleteItemAsync(key)
|
|
},
|
|
}
|
|
|
|
export const supabase = createClient(
|
|
process.env.EXPO_PUBLIC_SUPABASE_URL ?? '',
|
|
process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY ?? '',
|
|
{
|
|
auth: {
|
|
storage: ExpoSecureStoreAdapter as any,
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: false,
|
|
},
|
|
}
|
|
)
|