google log in for iphone (pc and android just works fine)

I've run into a tough issue that only affects iOS devices (both Safari and Chrome), and I'm hoping to get some advice on the best practice to solve it. The Problem: My React app uses Supabase Auth for Google Sign-In. The process works perfectly on PC and Android. However, on iPhones, after the user successfully authenticates with Google and is redirected back to my app, it gets permanently stuck on the initial loading screen and never navigates to after login page. The URL correctly shows the access_token in the hash, so the initial redirect is successful. What I've Already Tried: Verified URL Configuration: My Supabase Auth settings are correct (Site URL is set, and Redirect URLs includes the /** wildcard). Fixed redirectTo: My signInWithOAuth call correctly uses options: { redirectTo: window.location.origin }. Refactored Auth Logic: I've refactored my auth context and main app component to use onAuthStateChange as the single source of truth, eliminating any potential race conditions. My Question: What is the community's recommended, most robust pattern for solving this specific iOS post-login data fetching issue? Any advice or examples would be greatly appreciated. Thank you!
3 Replies
Ad Intellegent
@hyperjason this is often an iOS specific issue with how Safari handles localStorage/cookies after OAuth. A common fix is to use supabase.auth.exchangeCodeForSession() in your redirect handler instead of relying only on the hash token, so the session is fully restored
hyperjason
hyperjasonOP6d ago
Ok I will try Thaanks!!! hi I tried, but I am still stuck in loading page email login is working just fine, but google login only problem. I am still stuck in loading page.
Ad Intellegent
@hyperjason since email login works but Google login doesn’t, it’s likely an iOS specific session persistence issue. Sometimes you need to handle both exchangeCodeForSession() and explicitly refresh the session in your auth context after redirect. It can also be related to how the app initializes state on iOS. Hard to fully debug without looking at the project, but I’ve solved this exact Google OAuth + iOS issue before happy to share more details if needed

Did you find this page helpful?