Skip to content

Mobile auth session is not persisted across app restarts #264

@Midoriya-w

Description

@Midoriya-w

Problem

The mobile authentication flow currently does not persist user sessions across app restarts.

Inside apps/mobile/src/context/AuthContext.tsx, the auth provider contains TODO placeholders for loading and saving tokens, but no actual persistence implementation exists.

Current behavior:

  • User logs in successfully
  • App state holds token temporarily
  • Restarting the app clears authentication state
  • User must log in again every launch

Evidence

// TODO: Load token from secure storage on app start
useEffect(() => {
  setIsLoading(false);
}, []);

Expected behavior

  • Authentication token should persist securely across app restarts
  • Existing user sessions should be restored automatically on launch
  • Logout should properly clear persisted auth state
  • App should remain authenticated until token expiry or explicit logout

Suggested fix

Implement persistent auth storage using either:

  • expo-secure-store
  • @react-native-async-storage/async-storage

Possible implementation flow:

  1. Save token during login
  2. Restore token inside initial useEffect
  3. Re-fetch user profile if token exists
  4. Clear token on logout

This would significantly improve mobile UX and session continuity.

Why this matters

Currently the app behaves like a stateless session on mobile.

For a production mobile application, users generally expect:

  • persistent login
  • seamless relaunch experience
  • session continuity

Re-authenticating on every app restart creates unnecessary friction.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions