Setup
Peach needs no per-app install. You keep starting your app with the command you already use, and Peach connects to that dev server. A config file is optional; add one when you want what it gives you.
If you have not installed Peach yet, follow Installation first.
Expo and bare React Native (Metro)
Start Metro the way you normally do, from your app's project root:
# Expo
npx expo start
# bare React Native
npx react-native startThen, from the same directory, open the app in Peach:
peach open 8081Use your server's real port. Without a port, peach open scans for running
React Native dev servers and lets you pick one, and a bare peach opens the
same picker in the simulator.
Start your dev server from the app's project root. Peach reads your app's
configuration from the project root the server advertises, including your Expo
app config, custom fonts, splash screen and icon. If the server runs on another
machine or names no project root, pass --project-root <app-dir> to
peach open; without a project those details may be missing. Your Metro config
needs no changes.
One apps (beta)
Start your One app with its usual dev command, then open its port from the app's folder:
peach open <port>Peach reads the app's icon and widgets from its one() config and compiles
the app's Swift and Kotlin sources itself, so your One config needs no Peach
plugin.
Check your project first
Before you open an app for the first time, run:
peach compatIt reports the React and React Native your app declares, how much of each native library Peach implements, and any native code Peach does not know, with the config that answers it. Diagnosing your project walks through its output.
peach.config.ts
Most apps need no config. Add a peach.config.ts next to your package.json
when you need to answer native code Peach does not know, set environment
variables, or pin simulator settings for the app. Peach also accepts
peach.config.js, peach.config.mjs and peach.config.cjs.
// peach.config.ts
import type { PeachConfig } from 'peachsim/config'
export default {
// native modules and views Peach does not know, keyed by package
packages: {
'react-native-acme-analytics': 'noop',
},
// process.env values your code reads at runtime
env: { API_URL: 'http://localhost:3000' },
} satisfies PeachConfigThe import is type-only, so the file loads without installing anything. Add
peachsim as a dev dependency if you want editor types; peach setup offers to do that for you, along with a
peach script in your package.json. Peach reads the file each time it
loads your app, so your next reload picks up an edit.
The fields you are most likely to use:
| Field | What it does |
|---|---|
packages | Answers native modules and views Peach does not know, keyed by the package that asks for them. See Custom stubs. |
modules | Replaces a JavaScript module in your bundle with 'noop', an inline value, a project file, or another stub. Use it for packages you do not need in the simulator. |
env | Sets process.env.* inside your app at runtime. Values your bundler inlined at build time, such as EXPO_PUBLIC_*, need a rebuild of the bundle instead. |
settings | Overrides simulator settings such as device, appearance and locale for this app. |
initialState | Seeds starting state such as locale, color scheme and feature flags. |
network.remap | Rewrites a host:port your app fetches to another one, for suites that hardcode a port already in use on your machine. |
runtimeVersion | Pins the Peach runtime this project runs on. Omit it to use the current stable runtime. |
nativeRenderer | 'fabric' (the default) or 'paper', for apps whose native build turns the New Architecture off. |
The Configuration guide shows each slot with worked examples, and the PeachConfig reference lists every type.
Next
- •
Run your Expo app takes an existing Expo app all the way to a tested, shared preview.
- •
Wrap an existing app covers apps whose libraries need stubs before they run.