Start with the threat model
Every shipped mobile app is code running on a device you don't control. Anyone can unzip your IPA or APK, read the JavaScript bundle, and watch the traffic. Client-side security is about raising the cost of abuse and protecting users' data, not about hiding things from a determined attacker. Decide what you are protecting (user tokens, personal data, paid content, your API) and design so that a compromised client cannot do unbounded damage.
1. Keep secrets out of the bundle
The most common finding in mobile security reviews is a key embedded in the app. Environment variables inlined at build time (for example EXPO_PUBLIC_* values in Expo) are public by design. They end up in the bundle in plain text.
- Treat anything in the JS bundle as readable by everyone.
- Put third-party secret keys (payment, email, LLM providers) behind your own backend, which authenticates the user and calls the provider.
- Keys meant to be public (a maps key, an analytics write key) should be restricted server-side by bundle identifier, package name, or quota.
- Rotate anything that has ever been committed or shipped.
2. Store tokens in secure storage
AsyncStorage is unencrypted. For refresh tokens and session credentials use the platform keystores via expo-secure-store or react-native-keychain:
import * as SecureStore from 'expo-secure-store';
await SecureStore.setItemAsync('refresh_token', token, {
keychainAccessible: SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
});
Keep access tokens short-lived and in memory where possible. Secure storage has size limits, so store a small token, not whole objects. For larger local databases, use an encrypted option such as SQLCipher-backed SQLite and keep the key in the keystore.
3. Lock down the network
- HTTPS only. Don't weaken iOS App Transport Security or enable Android cleartext traffic in release builds.
- Validate on the server. Authorization, pricing, and entitlements are enforced by the API, never by a hidden screen or a flag in the app.
- Certificate pinning protects against a rogue CA or an intercepting proxy on a hostile network. It also has a real operational cost: if you pin a certificate that then rotates, every installed version stops working. Pin the public key (SPKI) rather than the leaf certificate, include a backup pin, and have a kill-switch or update path. Libraries such as
react-native-ssl-public-key-pinningimplement this natively; pinning inside JS alone does not work. For many apps, good server-side controls matter more than pinning, so make it a deliberate decision.
4. Understand what your bundle exposes
Hermes compiles JavaScript to bytecode, which is harder to casually read than minified JS but is not encryption; decompilers for Hermes bytecode exist. Enabling minification and stripping source maps from the shipped app (upload them to your crash reporter instead) is sensible hygiene. Commercial JS obfuscators can add friction, but they affect performance and bundle size, so measure before adopting. Don't rely on them for anything that must stay secret.
5. Jailbreak and root detection: signals, not guarantees
Libraries exist to detect rooted or jailbroken devices, and they are easy to bypass with instrumentation tools such as Frida. Use them as one signal for risk-based decisions (for example, step-up authentication before a high-value action), and do not make them the only gate. For stronger assurance, use platform attestation, Play Integrity API on Android and App Attest on iOS, and verify the result on your server.
6. Protect screens and data on the device
- Hide sensitive content in the app switcher. On Android,
FLAG_SECUREblocks screenshots and recents previews; on iOS, show a blur or placeholder view when the app becomes inactive. - Clear clipboard use for sensitive fields and mark them with
secureTextEntryand appropriatetextContentType/ autofill hints. - Validate deep link and intent parameters as untrusted input before navigating or calling an API with them.
- Log carefully. Strip tokens and personal data from analytics events and crash reports.
7. Dependencies and supply chain
A typical React Native app pulls in hundreds of npm packages. Commit your lockfile, run npm audit or an equivalent scanner in CI, review new native dependencies (they run with full app privileges), and pin versions for anything that touches auth or payments. Enable two-factor authentication on your npm and store accounts.
A short pre-release checklist
- No secret keys in the bundle; public keys restricted server-side.
- Tokens in the keychain/keystore, short-lived access tokens.
- HTTPS everywhere; authorization enforced on the server.
- Pinning decided deliberately, with backup pins and a recovery plan.
- Source maps not shipped; logs scrubbed.
- Attestation checked server-side for high-risk actions.
- Dependency audit in CI.
- Sensitive screens hidden in the app switcher.
Security reviews go much faster when these basics are already in place. If you'd like a second pair of eyes on a React Native codebase before a review or launch, get in touch.