Home / React Native App Architecture
React Native App Architecture for Scalable Projects
Good architecture keeps a React Native app fast to change, easier to test, and less painful to scale when the product grows from one or two screens into a real mobile platform.
A good React Native app architecture groups code by feature, keeps server state and client state in separate tools, routes every network call through one typed API layer, and isolates native code behind small interfaces so the rest of the app never knows which platform it is on. That combination keeps an app easy to change when it grows from five screens to fifty and from one developer to a team of ten. This guide shows the React Native architecture I use on production apps, with a folder structure you can copy, the trade-offs behind each choice, and a table for deciding how much structure your team actually needs.
Why architecture matters more in mobile than on the web
On the web, a bad deploy is fixed in minutes. In a mobile app, a native change takes a store review, users stay on old binaries for months, and a crash on launch can sit on thousands of devices. That pushes architecture toward three goals: changes that stay local to one feature, clear lines between JavaScript you can update over the air and native code you cannot, and seams where you can test logic without a simulator.
Planning a mobile app or stuck on one? Message me on WhatsApp or see how I work with app teams.
React Native folder structure: feature-based
The most common structure I inherit is "by type": one components/, one screens/, one hooks/, one services/ folder, each with hundreds of files. It works for a prototype and becomes painful at around 20 screens, because one feature change touches six folders and nobody knows what is safe to delete.
A feature-based architecture puts everything a feature needs in one place, and keeps genuinely shared code in a small shared layer:
src/
app/ # Expo Router routes only: thin files that render feature screens
(auth)/
sign-in.tsx
(tabs)/
_layout.tsx
orders/
index.tsx
[orderId].tsx
profile.tsx
_layout.tsx
features/
orders/
api/ # query keys, fetchers, mutations for this feature
orders.api.ts
orders.queries.ts
components/
OrderRow.tsx
OrderStatusBadge.tsx
screens/
OrdersListScreen.tsx
OrderDetailScreen.tsx
model/ # types, zod schemas, pure business logic
order.schema.ts
pricing.ts
pricing.test.ts
index.ts # the feature's public surface
auth/
profile/
shared/
api/ # HTTP client, auth interceptor, error types
ui/ # design system: Button, Text, Sheet, tokens
lib/ # formatting, dates, logging, analytics wrapper
native/ # typed wrappers around native modules
config/ # environment config
store/ # global client state (session, preferences)
Rules that keep this healthy:
- Features do not import each other's internals.
ordersmay import fromfeatures/authonly viafeatures/auth/index.ts. Enforce it with ESLintno-restricted-importsoreslint-plugin-boundaries, otherwise the rule erodes within a quarter. - Shared code must be earned. Something moves into
shared/when a second feature needs it, not before. - Route files stay thin. In Expo Router,
app/(tabs)/orders/[orderId].tsxjust reads params and rendersOrderDetailScreen. That keeps navigation concerns separate from feature logic and makes a router change cheap.
Navigation: Expo Router or React Navigation
Both are built on the same navigation primitives, so this is about developer experience rather than capability.
- Expo Router gives file-based routes, automatic deep linking (every route has a URL), typed routes, and web support. For new Expo apps I use it by default.
- React Navigation directly, with its static configuration API, suits bare apps with complex nested navigators or teams that prefer explicit navigation config.
Whichever you pick, two architectural decisions matter more: keep auth gating in one layout (a protected group that redirects to sign-in) rather than checks scattered in screens, and treat route params as untrusted input, because deep links can send anything. Validate them with the same zod schemas you use for API data.
Server state vs client state
The single change that simplifies most React Native codebases is separating these:
| Kind of state | Examples | Tool |
|---|---|---|
| Server state | Orders, products, user profile from the API | TanStack Query |
| Global client state | Session, theme, onboarding flags, cart before checkout | Zustand or Redux Toolkit |
| Local UI state | Is this sheet open, form field values | useState, React Hook Form |
| Persisted preferences | Language, last selected tab | Zustand persist with MMKV |
Putting API responses into Redux by hand means rewriting caching, deduplication, retries, background refetch and invalidation. TanStack Query does all of that, and with focusManager and onlineManager wired to AppState and NetInfo it refetches when the app returns to the foreground and pauses when offline.
After server state moves out, global client state is usually small. Zustand fits most apps with almost no boilerplate. Redux Toolkit still earns its place in large teams that want strict conventions, middleware and Redux DevTools time travel, or that already run RTK Query. I compare them in detail in the React Native state management guide.
The API layer
Screens should never call fetch directly. One client in shared/api handles base URL, auth headers, token refresh, timeouts, and error normalization. Each feature defines typed fetchers on top of it and validates responses at the boundary:
// features/orders/api/orders.api.ts
import { z } from "zod";
import { http } from "@/shared/api/http";
import { OrderSchema } from "../model/order.schema";
export async function getOrder(orderId: string) {
const data = await http.get(`/orders/${orderId}`);
return OrderSchema.parse(data); // fail loudly here, not deep inside a component
}
// features/orders/api/orders.queries.ts
import { queryOptions } from "@tanstack/react-query";
export const orderKeys = {
all: ["orders"] as const,
detail: (id: string) => [...orderKeys.all, id] as const,
};
export const orderQuery = (id: string) =>
queryOptions({ queryKey: orderKeys.detail(id), queryFn: () => getOrder(id) });
Validating at the boundary matters more in mobile than on the web, because an old app version may hit a newer API for months. When the backend changes a field, you get one clear, logged parse error rather than undefined is not an object in a render. If your backend team uses OpenAPI or GraphQL, generate the types and keep the schema check for the fields you depend on.
Error boundaries and failure handling
React error boundaries catch render errors, not errors in event handlers or async code. In production apps I place them at three levels:
- Root boundary: a full-screen "something went wrong" with a restart action, reporting to Sentry or Crashlytics.
- Per-route boundary: Expo Router lets each route export an
ErrorBoundary, so one broken screen does not take down the tab bar. - Per-widget boundary around risky, non-essential UI such as a recommendations carousel.
Pair this with TanStack Query's error states for data failures and a global handler for unhandled promise rejections, so async errors are logged too. Debugging those reports gets much easier with good source maps; my React Native debugging guide covers that setup.
Config and environments per build
Most apps need at least development, staging and production, each with its own API URL, bundle identifier and app name so testers can install staging next to production.
In Expo, use a dynamic app.config.ts driven by an environment variable set per EAS build profile:
// app.config.ts
const variant = process.env.APP_VARIANT ?? "development";
const ids = {
development: "com.example.app.dev",
staging: "com.example.app.staging",
production: "com.example.app",
} as const;
export default {
name: variant === "production" ? "Example" : `Example (${variant})`,
ios: { bundleIdentifier: ids[variant] },
android: { package: ids[variant] },
extra: { apiUrl: process.env.EXPO_PUBLIC_API_URL },
};
Read config through one typed module in shared/config and validate it at startup. Remember that anything exposed to JS is visible in the bundle, so only public values belong there; secrets stay on the server. Bare apps get the same result with Android product flavors and iOS schemes plus react-native-config.
Native module boundaries
Native code is the most expensive part of the app to change, because it needs a store release. Keep it behind a narrow, typed interface in shared/native:
- Features call
biometrics.authenticate()from your wrapper, never the third-party library directly. Swapping libraries later touches one file. - Wrappers expose plain promises and typed results, and handle platform differences internally.
- For your own native code, use Turbo Modules or Nitro Modules with a TypeScript spec, so the interface is generated and type-checked. See my TurboModules guide.
This boundary also defines your OTA safety line: changes above it can ship through EAS Update; changes below it need a new binary.
Testing seams
Architecture is what makes testing affordable. The seams I rely on:
- Pure logic in
model/(pricing, validation, state transitions) tested with Jest, no rendering needed. This is where most bugs that cost money live. - API mocking at the network layer with MSW, so screen tests exercise real hooks and real TanStack Query behavior.
- Native wrappers mocked once in Jest setup, which is only possible because features never import native libraries directly.
- End-to-end flows in Maestro or Detox for login, purchase and other critical paths.
When a monorepo helps
A monorepo is worth it when you have more than one app sharing code: a customer app and a driver app, a mobile app and a Next.js web app sharing API types and validation, or a design system used across products. pnpm or Yarn workspaces with Turborepo work well, and Metro supports monorepos out of the box in current Expo SDKs. For a single app with one team, a monorepo adds tooling cost without much benefit. The Expo monorepo guide covers the setup when you do need one.
React Native clean architecture: how far to go
Strict clean architecture, with use-case classes, repositories and dependency injection containers for every call, is usually too heavy for React Native. You get most of its value from three lighter rules: business logic in pure functions, I/O behind the API and native layers, and features that depend on shared code but not on each other.
| Decision | Small team (1 to 4 devs) | Larger team (5+ devs or multiple squads) |
|---|---|---|
| Folder structure | Feature folders, light shared layer | Feature folders with enforced import boundaries |
| Navigation | Expo Router | Expo Router or React Navigation with typed routes |
| Server state | TanStack Query | TanStack Query with shared query key conventions |
| Client state | Zustand | Zustand or Redux Toolkit for stricter conventions |
| API types | Hand-written zod schemas | Generated from OpenAPI or GraphQL, validated at the edge |
| Native code | Community libraries via wrappers | Wrappers plus own Turbo or Nitro modules with owners |
| Testing | Jest on logic, a few Maestro flows | Jest, MSW screen tests, E2E in CI on every PR |
| Repo | Single app repo | Monorepo if two or more apps share code |
The official React Native documentation covers the platform pieces; the structure on top is up to you. If you want a second opinion on your current codebase or a plan for scaling it, talk to me about a React Native architecture review.
FAQ
What is the best folder structure for a React Native app?
For most apps, a feature-based structure: one folder per product feature containing its screens, components, API calls and logic, plus a small shared layer for the design system, HTTP client and native wrappers. It scales better than grouping by file type because changes stay local to one feature.
Should I use Redux in a new React Native app?
Usually not as the first choice. Move API data to TanStack Query, and the remaining global state is often small enough for Zustand. Redux Toolkit is still a solid option for large teams that value strict patterns and its tooling.
Is clean architecture worth it in React Native?
The principles are, the full ceremony usually is not. Keep business logic in pure, tested functions and put networking and native code behind interfaces. That gives you testability and replaceable dependencies without layers of boilerplate.
Expo Router or React Navigation?
For new Expo projects, Expo Router, because file-based routes give you deep linking, typed routes and web support with little setup. React Navigation remains a good choice for bare apps or teams that want explicit navigator configuration. Both share the same underlying navigation library.
