Template for a React Native app on 0.84.x with TypeScript, navigation, persisted state, i18n, and a small UI layer. Use it as a base: rename the app, adjust env and API code, then build your product.
- React Native environment setup (Xcode, Android SDK, etc.)
- Node.js
>= 22.11.0(seepackage.jsonengines)
-
Install dependencies
yarn install
-
Environment variables
Copy the sample env file and edit values as needed:
cp .env.sample .env
The Babel config loads
.envviareact-native-dotenvusing the@envmodule. A sample variableAPI_URLis listed in.env.sample. Use it in React Query fetchers, for examplefetch(\${API_URL}/users`)(add a small*.d.tsfor@env` if TypeScript complains). -
iOS — CocoaPods
From the project root:
yarn pod-install
Or use
bundle installandbundle exec pod installunderios/if you rely on the Gemfile there.
yarn android
# or
yarn ios| Script | Purpose |
|---|---|
yarn start |
Start Metro |
yarn android |
Run on Android |
yarn ios |
Run on iOS |
yarn pod-install |
Install iOS pods via npx pod-install |
yarn test |
Run Jest |
yarn lint |
Run ESLint |
- TypeScript with path alias
@/→src/(seebabel.config.jsandtsconfig.json). - React Navigation — stack navigator in
src/navigators/Application.tsx; route param types insrc/types/navigation.d.ts. - Zustand + MMKV — example user session store with persistence (
src/stores/userStore.ts,src/stores/mmkvStorage.ts).App.tsxwaits for rehydration before rendering. - i18next / react-i18next — initialized in
src/translations/index.tswith English and Vietnamese resources undersrc/translations/resources/. - Theming — tokens in
src/theme/(colors, spacing, typography, borders). - UI primitives —
Button,Input,Text,SafeAreaViewundersrc/components/(with example tests). - Data fetching — TanStack React Query (
@tanstack/react-query) withsrc/services/queryClient.ts(seesrc/services/README.md).src/services/post.ts+Homeshow a minimaluseQueryflow.App.tsxwraps the tree inQueryClientProviderand ties query focus toAppStateon native.
Native gesture handling is set up via gesture-handler.js / gesture-handler.native.js and imported from App.tsx.
src/
components/ # Reusable UI
navigators/ # Navigation containers / stacks
screens/ # Screen components (e.g. Home, SignIn)
services/ # API services
stores/ # Zustand stores + MMKV storage adapter
theme/ # Design tokens
translations/ # i18n setup and locale files
types/ # Shared TypeScript types (navigation, i18n)
utils/ # Helpers
App.tsx # Root: SafeAreaProvider, hydration, navigator
- Rename the app — Update
nameanddisplayNameinapp.jsonand thenamefield inpackage.jsonto match your product. - Navigation — Add screens to
src/screens/, export them fromsrc/screens/index.ts, register routes inApplication.tsx, and extendApplicationStackParamListinsrc/types/navigation.d.ts. - Locales — Add namespaces or languages under
src/translations/resources/and register them insrc/translations/index.ts. - Auth / gating — The stack switches between
SignInandHomebased onuseUserStore’sisLoggedIn; replace or extend this flow as needed. - APIs with React Query — Read
src/services/README.mdand followsrc/screens/Home/useDemoPostsQuery.ts(used on the Home screen): query keys,fetchin the query function,useQueryin a small hook. Copy that shape per resource; adduseMutationwhere you write data.
- Jest — Config in
jest.config.js; setup injest.setup.js. Test files use the*.test.ts(x)pattern. - ESLint — Extends React Native and Airbnb-related rules; run
npm run lint.
If builds or Metro fail, use the official React Native troubleshooting guide and confirm your toolchain matches the version pinned in this repo.