mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES Reworks Expo React native social to use appropriate auth methods and restructures to use external code. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
35 lines
907 B
TypeScript
35 lines
907 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_ANON_KEY ?? '',
|
|
{
|
|
auth: {
|
|
storage: ExpoWebSecureStoreAdapter,
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: false,
|
|
},
|
|
},
|
|
);
|