Skip to content

Mobile Auth Navigation Bootstrap

Ankit Upadhyay edited this page Jul 24, 2026 · 2 revisions

Mobile: Auth, Navigation, Bootstrap

How the app starts, authenticates, and routes. Part of Mobile Overview.

Bootstrap

  • index.js registers push background handlers (setBackgroundMessageHandler, notifee.onBackgroundEvent) before AppRegistry.registerComponent.
  • App.tsx is the real bootstrap: initializes SuperTokens (initSuperTokens) and the social providers (configureSocialProviders), loads remote mobile config (fetchMobileConfig), resolves the API base URL into API_CONFIG, evaluates the app-update prompt, initializes PostHog + Stripe, and mounts the provider tree: Provider(store)PersistGateGestureHandlerRootViewSafeAreaProviderAuthProviderPreferencesProviderGlobalLoaderProviderAppUpdateGateNotificationBootstrapStripeProviderNavigationContainerAppContent (renders AppNavigator inside an ErrorBoundary).

Auth

src/features/auth/:

  • authSlice.ts (auth slice), thunks.ts (initializeAuth, establishSession, refreshSession, updateUserProfile, logout), selectors.ts, sessionManager.ts (token freshness, getFreshStoredTokens, isTokenExpired).
  • context/AuthContext.tsxAuthProvider / useAuth (isLoggedIn, user, AuthTokens).
  • Services: superTokensClient.ts (SDK init), authUserService.ts, passwordlessAuth.ts, socialAuth.ts (configureSocialProviders), tokenStorage.ts, accountDeletion.ts; hook useSocialAuth.ts.
  • Screens: SignInScreen, SignUpScreen, CreateAccountScreen, OTPVerificationScreen.

The auth backbone is SuperTokens (supertokens-react-native) since the SuperTokens migration landed (PR #1763, merged 2026-07-16): superTokensClient.ts initializes the SDK, passwordlessAuth.ts drives email-OTP sign-in, and socialAuth.ts exchanges Google/Apple credentials through SuperTokens signinup (exchangeWithSuperTokens). The former Amplify (Cognito) and Firebase auth paths survive only as legacy stored-token cleanup (tokenStorage.ts LegacyAuthProviderName, sessionManager.ts); Firebase otherwise remains for push messaging.

Navigation

React Navigation 7:

  • AppNavigator.tsx — root native stack with Onboarding, Auth, Main, choosing which to render from auth/onboarding state (useAuth, subscribeOnboarding, sessionManager token freshness), and mounting EmergencyProvider, NetworkProvider, and co-parent invite handling.
  • AuthNavigator.tsxSignIn, SignUp, OTPVerification, CreateAccount, TermsAndConditions, PrivacyPolicy.
  • TabNavigator.tsx — bottom tabs with a custom FloatingTabBar: HomeStack, Appointments, Documents, Tasks, each a nested native stack.
  • Per-feature stacks: HomeStackNavigator, AppointmentStackNavigator, DocumentStackNavigator, TaskStackNavigator, ExpenseStackNavigator, LinkedBusinessesStackNavigator, AdverseEventStackNavigator. All param lists live in src/navigation/types.ts; onboarding state in navigation/onboardingStore.ts.

Related

Product & Domain
Architecture
Applications
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Roadmap
Operations
Meta

Canonical code & docs: main repo · Auto-generated companion: DeepWiki

Clone this wiki locally