Documentation comes from this release commit, without inheriting newer content. Commit: cc3dd17e61.
Feature — Auth
Sign-in, sign-up, sign-out, and the user profile screen. Session is persisted in MMKV. Backed by a mock API today; swap to a real backend by editing api.ts only.
Files
Routes:
Types at a glance
Auth store
- MMKV key:
auth partializewhitelists onlysession—hydratedis local-only.onRehydrateStoragecallssetHydrated()so screens can wait for storage if needed (currently MMKV is synchronous so this fires immediately).
Mutations
The screen never calls router.replace. It just runs the mutation; setSession updates the store, the root layout's <Stack.Protected guard={hasCompleted && !!session}> becomes the active block, and Expo Router mounts (app)/(tabs). See routing.md for the full guard model.
useSignOutMutation additionally calls queryClient.clear() so cached server data doesn't leak between users.
Form
AuthForm is shared between sign-in and sign-up — the mode prop conditionally shows the displayName field. The parent owns the mutation; the form is a controlled trio of inputs + submit button.
Mock API behaviour
api.ts simulates latency (400-800 ms) and rejects obviously bad inputs (no @, too-short password, empty display name). It returns a generated SessionDto so the rest of the stack can be exercised without a backend.
When wiring to a real API:
- Replace bodies of
signInRequest/signUpRequest/signOutRequestwithapiClient.post(...)/.delete(...)calls. - Make sure the DTO shape from the server matches
SessionDto; if not, adjusttypes.ts+mappers.ts. - Add
apiClientgetAuthToken: () => useAuthStore.getState().session?.accessTokenso subsequent calls are authenticated.
Profile screen
Reads useAuthStore().session for display and exposes:
- Sign out →
useSignOutMutation.mutate(). Mutation'sonSuccessflipssessiontonull; root layout's<Stack.Protected>swaps to(auth)/sign-in. Noroutercall. - Reset onboarding flow → closes paywall,
useOnboardingStore.getState().reset(),useTutorialStore.getState().reset(), andsignOut(). The onboarding guard has the highest priority, so the root layout mounts(onboarding)for the full onboarding → paywall → tutorial sequence. Noroutercall.