Skip to main content

Isomorphic Session Consistency

Archibald is designed for cross-platform development (Web and Native). Maintaining a consistent user experience as users switch between their browser and the mobile app is a critical best practice.

Unified User Model

Ensure that your User interface is shared between your web and native packages (typically by placing it in a core logic package).

  • Do: Use the same Custom User Model generic across both SessionClient (Web) and SessionClient (Native).
  • Don't: Define platform-specific user properties that aren't mapped in the backend, as this will lead to hydration errors and type inconsistencies.

Session Parity

While the storage mechanisms differ (CookieAuthAdapter for Web, HeaderAuthAdapter for Native), the underlying session data in the JWE should be identical.

  • The "Silent Refresh" Rule: Both platforms should be configured with matching refresh intervals. If your backend JWE expires in 15 minutes, both the Web and Native SessionClient should have a refresh interval of ~10 minutes to ensure a seamless transition for the user.
  • Storage Persistence: In Native apps, use a secure storage adapter (like CustomNativeStorageAdapter using expo-secure-store) to ensure the user isn't logged out when the app is closed, mirroring the persistence of secure cookies on the web.

Shared State vs Platform State

Only store authentication-related data in the session.

  • Shared: User IDs, Roles, Scopes, Base Profile.
  • Platform-Specific: Device tokens for push notifications or local theme settings should be handled via the DataClient or platform-specific storage, not injected into the core authentication user profile.