How to handle Supabase Auth in offline-first React Native apps without logging users out?

Hey,
I'm using Supabase Auth in a React Native app, and I'm running into a problem with offline support.

When a user opens the app without an internet connection, the session eventually expires after refresh token retries fail, and the user is logged out. This breaks the offline first experience ideally, the user should stay logged in and be able to access locally stored content even without connectivity. For context this is not possible as the app only allows access to certain screens if the user is authenticated.

What I’d like to achieve:
  • The user opens the app without internet and stays logged in.
  • Once the connection is restored, the session refreshes normally in the background.
  • The user is only logged out if the refresh token is truly invalid not just because there was no connection at the time.
From what I’ve read, this behavior seems to be tied to how auth handles session persistence and refresh. I’ve gone through these related discussions but haven’t found a clear workaround:
Has anyone figured out a workaround?

Thanks
GitHub
In my React Native app, Supabase Auth does not persist user sessions when the app is started without internet access. Even though persistSession: true and AsyncStorage are set, the user is logged o...
GitHub
Bug report Describe the bug By looking at the code here, it seems like whenever user opens the app while offline, the session is deleted. const { error } = await this._callRefreshToken(currentSessi...
GitHub
Good evening, We are developing an application using React Native with the Expo framework, and Supabase as the backend. One of our key requirements is offline functionality. While we've found m...
Was this page helpful?