Here's my setup:
When a user taps the "Sign Up" button or uses "Sign Up With Google / Apple," they are redirected to the onboarding page.
However, there’s a potential edge case:
If a user signs in, lands on the onboarding page, exits the app, and then reloads it, they are redirected to the home page without completing the onboarding process.Proposed Solution (but facing a critical issue):
I currently use an on page load action on the home page (the page users land on after authenticating on login). This action:
Checks if the user has completed onboarding (using a Boolean field, e.g.,
isOnboarded
, stored in Firebase).If
isOnboarded
istrue
, the user stays on the home page.If
isOnboarded
isfalse
, the user is redirected to the onboarding page.
Issue:
Sometimes, Firebase doesn’t fetch theisOnboarded
value quickly enough before the app determines whether to show the onboarding flow or not. This creates a race condition, where:Users who have already completed onboarding may still be redirected to the onboarding page due to the delay in retrieving the Boolean value.
What is the best way to address this race condition? Are there alternative approaches or best practices?