Skip to content

Commit 76ee822

Browse files
committed
store session on web
1 parent 1f7bdab commit 76ee822

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
]
2424
},
25-
"buildNumber": "5"
25+
"buildNumber": "6"
2626
},
2727
"android": {
2828
"adaptiveIcon": {

db/supabaseClient.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,31 @@ if (!supabaseUrl || !supabaseAnonKey) {
1111
// Don't throw immediately, let the app handle this gracefully
1212
}
1313

14+
// Create a localStorage adapter for web
15+
const localStorageAdapter = typeof window !== 'undefined' ? {
16+
getItem: (key: string) => {
17+
return Promise.resolve(window.localStorage.getItem(key));
18+
},
19+
setItem: (key: string, value: string) => {
20+
window.localStorage.setItem(key, value);
21+
return Promise.resolve();
22+
},
23+
removeItem: (key: string) => {
24+
window.localStorage.removeItem(key);
25+
return Promise.resolve();
26+
},
27+
} : undefined;
28+
1429
// Create a single, shared Supabase client instance
15-
// On web, disable storage (no session persistence)
30+
// On web, use localStorage for session persistence
1631
// On native, use AsyncStorage for session persistence
1732
export const supabaseClient = createClient(supabaseUrl, supabaseAnonKey, {
1833
auth: {
1934
...(Platform.OS === 'web'
2035
? {
21-
// Disable storage on web
22-
storage: undefined,
23-
persistSession: false,
36+
// Use localStorage on web for session persistence
37+
storage: localStorageAdapter,
38+
persistSession: true,
2439
// Enable URL detection for OAuth redirects on web
2540
detectSessionInUrl: true,
2641
}

0 commit comments

Comments
 (0)