How to mock API calls in React Native

How to mock API calls in React Native and Expo: compare stubs, MSW (msw/native), a React Native mock server, and Mockifyer record-replay for fetch and axios, including Redis/SQLite global storage for shared scenarios.

Why mock for offline development

Mock HTTP so you can develop offline, demo stable states, keep Detox/Maestro deterministic, and build UI before backends ship.

Mock fetch and axios in React Native

Install @sgedda/mockifyer-fetch, configure Metro with configureMetroForMockifyer, and call setupMockifyerForReactNative. For axios use @sgedda/mockifyer-axios with useGlobalAxios: true. Record selectively into _scratch until you activate mocks.

Global storage / shared mocks

Run the dashboard with --provider redis (or sqlite) so mocks and scenarios live in a shared store. Point the app with initMockifyerForReactNativeDashboard or proxyBaseUrl so teammates, CI, and demo devices load the same recordings without local mock-data files.