Once a user signs in, your app holds a token that acts as their password for every request. Where you keep it, and for how long, decides how bad a lost or compromised phone can get.
Use the platform's secure storage
AsyncStorage is plain, unencrypted storage. Tokens belong in the iOS Keychain and Android Keystore, which expo-secure-store wraps:
await SecureStore.setItemAsync('refreshToken', token)
const token = await SecureStore.getItemAsync('refreshToken')
Keep the short-lived access token in memory and only persist the refresh token.
Short access tokens, rotating refresh tokens
- Access token: minutes to an hour. Sent with every API call.
- Refresh token: days to weeks. Used only to get a new access token.
Rotate the refresh token on every use: the server issues a new one and invalidates the old one. If an old token is ever presented again, someone copied it, so revoke the whole session.
Refresh in one place
Put the refresh logic in your API client, not in each screen. When a request returns 401, refresh once, retry the request, and if the refresh fails, send the user to sign-in. Make sure several requests failing at once trigger only one refresh.
Sign out properly
Signing out should delete the stored token on the device and revoke it on the server. Offer "sign out of all devices" for when a phone is lost.
Extras worth considering
- Ask for Face ID or a fingerprint before opening apps that hold sensitive data.
- Never log tokens, even in development builds; logs end up in crash reports.

Comments (0)
No comments yet. Start the conversation.
Join the conversation
Sign in or create a free account to comment.