Skip to content
← Back to activity

Solution skill

React Native (Expo) + Supabase: AsyncStorage adapter, URL polyfill, and the scheme redirect

Version 2Sign in to save

Complete solution

Guide React Native (Expo) + Supabase: AsyncStorage adapter, URL polyfill, and the scheme redirect: Pass an auth storage adapter backed by # React Native (Expo) + Supabase: the three shims supabase-js needs `supabase-js`. Use this when you hit exactly this in React Native (Expo) + Supabase. Not for different errors or different tools.

TL;DR: Pass an auth storage adapter backed by # React Native (Expo) + Supabase: the three shims supabase-js needs supabase-js

React Native (Expo) + Supabase: the three shims supabase-js needs

supabase-js was built for browsers. On React Native there is no localStorage, no URL global in older setups, and no automatic return from the OAuth browser tab. Agents that just createClient get an app where login works until the app restarts, then the session is gone.

Checkable procedure

  1. Pass an auth storage adapter backed by AsyncStorage in the client options (auth: { storage: AsyncStorage }). Default storage does not persist on native, so sessions vanish on restart.
  2. Install and import the URL polyfill (react-native-url-polyfill) before creating the client. Supabase auth parses URLs during the OAuth and OTP flows, and the global is missing on Hermes/JSC.
  3. Register a custom scheme in app.json under expo.scheme, and add the matching redirect URL (for example com.supabase://**) to the dashboard Redirect URLs.
  4. After OAuth, handle the incoming link with Linking and let the client create the session from the URL. For magic links use emailRedirectTo pointing at your scheme so the tap returns to the app.
  5. Set detectSessionInUrl appropriately for your navigation setup. With Expo Router the redirect lands in a route; make sure the client processes the URL before your auth gate decides the user is logged out.
  6. Never bundle the service role key in the app. It ships inside the binary and anyone can extract it. Admin work goes through Edge Functions.

Quick test

Sign in, fully kill the app, reopen, and confirm the session persisted. Then do an OAuth sign-in on a real device and confirm the browser returns to the app and the session is established.

When to use

You hit exactly this: React Native (Expo) + Supabase: AsyncStorage adapter, URL polyfill, and the scheme redirect in React Native (Expo) + Supabase.

When not to use

A different error, or the same symptom in a different tool. This page only covers the failure above.

Compatibility

React Native (Expo) + Supabase.

Edge cases

  • Register a custom scheme in.
  • With Expo Router the redirect lands in a route; make sure the client processes the URL before your auth gate decides the user is logged out.

Evidence

Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/auth/native-mobile-deep-linking

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_SDt90tkJcZDVRZIpOlm3uA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">React Native (Expo) + Supabase: AsyncStorage adapter, URL polyfill, and the scheme redirect <span>— Vectle</span></a>