React Native and Expo¶
Scope: iOS and Android apps built with React Native and Expo, on React Native 0.88 and Expo SDK 58, the current releases. React Native has run only on the New Architecture since version 0.82, and Expo since SDK 55, and Hermes V1 has been its default JavaScript engine since 0.84. Components follow the React rules, such as pure components (REACT-1) and separate server state (REACT-5), and the TypeScript rules apply to the code. Keeping secrets out of the app (SEC-11) and running supported releases (SEC-17) are in Security, third-party SDKs and personal data in Privacy and personal data, and sign-in in Authentication and sessions. Store requirements and privacy declarations are in Mobile games (MOBGAME-5, MOBGAME-6), and they apply to every app. Native code is covered in iOS (Swift and SwiftUI) and Android.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
- 9 React Native documentation: the baseline for React Native: core components and APIs, platform-specific code, native modules, performance, security, testing and upgrades.
- 9 OWASP Mobile Application Security Verification Standard (MASVS): the security requirements for mobile apps: storage, cryptography, authentication, network communication, platform interaction, code quality, resilience and privacy. The OWASP MASTG describes how to test each of them on iOS and Android.
- 8 Expo documentation: the baseline for Expo apps: development builds, app config and Continuous Native Generation, Expo Router, the Expo SDK, and building, submitting and updating apps with EAS.
- 8 Security (React Native): storing sensitive data, deep links, OAuth with PKCE and network security in React Native apps.
- 7 Expo Router (Expo): file-based routing for Android, iOS and web, with deep links to every screen, protected routes and typed routes.
- 7 Expo Update (Expo, formerly EAS Update): over-the-air updates of JavaScript and assets, with runtime versions, channels, rollouts, rollbacks and code signing.
- 7 EAS Build and EAS Submit (Expo): hosted builds of app binaries, signing credentials, and submission to the App Store and Google Play from CI.
- 7 Performance overview (React Native): the JavaScript and UI threads, and the common causes of dropped frames, such as development mode, large lists and work on the JavaScript thread during animations.
Key rules¶
Project setup¶
- 7
RN-1Start new apps with Expo and Expo Router, and develop in development builds rather than in Expo Go. The React Native docs recommend a framework for new apps and name Expo; Expo recommends Expo Router for new apps, and calls Expo Go a limited playground that isn't useful for production-grade projects. This appliesREACT-7. (React Native, Get started, Expo Router, Introduction, Expo, Develop an app with Expo) - 7
RN-2Generate theiosandandroiddirectories with Prebuild (Continuous Native Generation): keep native configuration in the app config and config plugins, keep the generated directories out of Git, and don't edit them by hand. Expo highly recommends Prebuild, which automates upgrades, and manual changes to the generated directories are lost the next time it runs with--clean. (Expo, Continuous Native Generation) - 6
RN-3Write the app in TypeScript withstricton (TS-1), and turn on Expo Router's typed routes, so that the type checker reports links to routes that don't exist.expo/tsconfig.baseleavesstrictoff, so set it in the project's owntsconfig.json. (Expo, Using TypeScript, Typed routes)
Secrets, storage and sign-in¶
- 9
RN-4Treat the JavaScript bundle and the app config as public: never put secrets inEXPO_PUBLIC_variables, the app config or the code, and call services that need a secret through your own server. Expo inlinesEXPO_PUBLIC_variables into the bundle in plain text, and most app config fields are readable at run time;npx expo config --type publicshows what a build exposes. This appliesSEC-11. (Expo, Environment variables, Configure with app config, React Native, Storing sensitive info) - 9
RN-5Store tokens and other secrets withexpo-secure-store, which uses the iOS Keychain and the Android Keystore, not in AsyncStorage, which is unencrypted, or in a persisted state store, and keep them out of crash reports and analytics. This is how React Native apps applySEC-19. (React Native, Async Storage, Secure storage, Expo, SecureStore) - 9
RN-6Sign users in through the system browser withexpo-auth-sessionorreact-native-app-auth, using the authorization code flow with PKCE (AUTH-2), never in a WebView, and exchange the code on your server when the provider requires a client secret. Any app can register your URL scheme, and RFC 8252, the best current practice for OAuth in native apps, says that apps must not use embedded user agents for authorization requests.IOS-7is the same rule for native iOS apps. (React Native, OAuth2 and redirects, Expo, Authentication with OAuth or OpenID providers, IETF, RFC 8252, 8.12 Embedded user agents) - 8
RN-7Treat every incoming link as untrusted input: validate its route and query parameters before using them (SEC-10), never put tokens or personal data in a link, and use universal links and Android App Links for links that must open only your app. Expo Router makes every screen deep-linkable, and any app can register the same custom scheme. Protected routes only stop client-side navigation, so your server must still authorize every request (SEC-1). (React Native, Authentication and deep linking, Expo, Linking overview, Expo Router, Protected routes)
Privacy¶
- 7
RN-8Declare the required reason APIs that the app and its libraries use inios.privacyManifestsin the app config, copying the reasons from each library'sPrivacyInfo.xcprivacy. Apple doesn't correctly read every privacy manifest in static CocoaPods dependencies, such as Expo SDK packages, so their reasons may need to be in the app's own manifest. This is how Expo apps followIOS-9. (Expo, Privacy manifests, Apple, Describing use of required reason API)
EAS Build, Submit and Update¶
- 7
RN-11Build and submit releases with EAS Build and EAS Submit from CI, and let EAS manage the signing credentials. If you use local credentials, addcredentials.jsonand the keystore and certificate files to.gitignore(SEC-2). (Expo, Using automatically managed credentials, Using local credentials, Submit to app stores) - 6
RN-9Give every build a runtime version that changes whenever its native code changes, preferably with thefingerprintpolicy, test each update on a preview build of the same runtime version through its own channel, and release it to production as a rollout to a small share of users first. Cancel the rollout, or roll back, if the error rate rises. An update that calls native code the build doesn't contain fails, andexpo-updatesmay have to roll back to the previous update. Roll out store releases gradually as well (MOBGAME-12). (Expo, Runtime versions and updates, Rollouts, Rollbacks) - 6
RN-10Use over-the-air updates for bug fixes and other changes that the stores allow without review, and ship new features and changes to the app's purpose in a store build. The App Store doesn't allow downloaded code that introduces or changes features, Expo notes that changes to an app's behaviour usually need review, and Google Play allows JavaScript loaded at run time only if it doesn't break its policies. See alsoMOBGAME-8. (Apple, App Review Guidelines 2.5.2, Expo, Expo Update, Google Play, Device and Network Abuse) - 5
RN-12If your EAS plan includes it, sign updates end to end withexpo-updatescode signing, and keep the private key out of source control. The app verifies each update's signature before applying it, so nobody between you and the device, not even EAS, can tamper with updates. (Expo, End-to-end code signing with Expo Update)
Performance¶
- 7
RN-13Render long or growing lists with a virtualized list,FlatList,SectionListor FlashList, not with.map()inside aScrollView, and measure performance in release builds.ScrollViewrenders all its children at once, whileFlatListrenders items as they are about to appear, and FlashList, a drop-in replacement that the Expo SDK supports, recycles item components. Development mode makes the JavaScript thread much slower. (React Native, ScrollView, Optimizing FlatList configuration, Expo, FlashList, React Native, Performance overview) - 6
RN-14Turn on the React Compiler after checking the project withreact-compiler-healthcheck, and in new code rely on it for memoization, withuseMemoanduseCallbackonly where you need precise control. The compiler memoizes components and hooks to avoid unnecessary re-renders, and it relies on code that follows the Rules of React (REACT-1). (Expo, React Compiler, React, React Compiler introduction)
Upgrades and testing¶
- 8
RN-15Stay on a React Native release that still gets fixes, one of the latest three minor versions, by upgrading one Expo SDK at a time: runnpx expo install --fixandnpx expo-doctor, and apply native changes with the Upgrade Helper if you don't use Prebuild. Choose libraries that are maintained and support the New Architecture, starting with the Expo SDK and React Native Directory. This appliesSEC-17, and the stores' build requirements (MOBGAME-5) set the deadlines. (React Native, Releases overview, Upgrading to new versions, Expo, Upgrade Expo SDK, React Native's New Architecture: third-party libraries) - 7
RN-16Test components with Jest, thejest-expopreset and React Native Testing Library, finding elements as users do (WEB-14), and cover the few critical journeys with Maestro end-to-end flows that run in CI, for example on EAS Workflows. (Expo, Unit testing with Jest, React Native, Testing, Expo, Run E2E tests on EAS Workflows with Maestro)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 6 Expo Doctor:
npx expo-doctorchecks that dependencies match the installed Expo SDK, validates them against React Native Directory to flag unmaintained libraries and those untested or incompatible with the New Architecture, and warns when theiosandandroiddirectories are committed although the app config holds native settings that only Prebuild applies. Run it in CI. Partly checksRN-2andRN-15. - 6 eslint-config-expo: the ESLint configuration that
npx expo lintsets up. It includes the recommendedeslint-plugin-react-hooksrules and, from SDK 55, the React Compiler rules, which flag code that breaks the Rules of React. Partly checksRN-14. - 6 TypeScript type checking: run
tscin CI withstricton and typed routes generated, and it reports type errors andhrefvalues that aren't valid routes. It can't tell whetherstrictis off. Partly checksRN-3.
Tutorials and further reading¶
- 7 Tutorial: Using React Native and Expo (Expo): building a universal app for Android, iOS and the web with Expo and Expo Router.
- 6 Accessibility (React Native): accessibility properties, roles, labels and actions for screen readers on iOS and Android.
- 6 Use a framework to build React Native apps (React Native blog): why the React Native team recommends starting with a framework such as Expo.