On-device live code editor and AI agent for React Native. Edit TSX on your phone, save, and see the preview update — no Metro connection required after install.
npm install code-reloadcode-reload/ ← this package (ios/, android/, src/)
example/ ← demo app (start here)
src/App.tsx ← edit this
appSources.ts ← auto-generated snapshot (gitignored)
- React Native dev environment (Xcode for iOS, Android Studio for Android)
- Node.js ≥ 22.11
- CocoaPods (for iOS)
From the repo root:
cd example
npm install
cd ios && pod install && cd ..Use two terminals from example/, or run Metro in the background first.
Terminal 1 — Metro
cd example
npm startprestart runs code-reload-snapshot automatically, which copies src/**/*.tsx into a bundled snapshot for the on-device editor.
Terminal 2 — iOS (physical device or simulator)
cd example
npm run ios -- --scheme CodeReloadFreshRNThe example Xcode scheme is CodeReloadFreshRN (not the default CodeReloadExample).
Android
cd example
npm run android- Change
example/src/App.tsxin your editor. - Reload the preview:
- With Metro: save and use Fast Refresh, or press
Rin the dev menu. - On device (Code Reload Files tab): open
App.tsx, edit, tap Save — works offline after the app is installed.
- With Metro: save and use Fast Refresh, or press
Do not edit example/appSources.ts; it is generated by npm run snapshot and gitignored.
In __DEV__, the app mounts Code Reload: tap the floating button to open Files, Chat, and History.
If App.tsx is missing from Files after a rebuild, you may see “Bundled code changed” — choose Replace to seed from the latest snapshot, or delete and reinstall the app.
import { registerCodeReloadApp, AI_MODELS } from 'code-reload';
import App from './src/App';
import { appSources } from './appSources';
registerCodeReloadApp('MyApp', App, {
sources: appSources,
entry: 'App',
apiKey: 'your-key-here',
model: AI_MODELS.claude4Sonnet,
});Generate the snapshot from your source tree:
node ../scripts/code-reload-snapshot.js --src src --out appSources.tsOr use the code-reload-snapshot bin from this package.
npm run typescript # typecheck code-reload package
npm run snapshot # snapshot with default paths (src → src/appSources.ts)Published as code-reload on npm. CI publishes on push to main when package.json version is not already on the registry.
- Bump
versionin package.json in your release PR. - Merge to
main(or run Publish to npm via Actions → workflow_dispatch). - On npm, configure trusted publishing for
code-reload→ GitHub →mikemilla/code-reload, workflow filenpm-publish.yml. CI uses OIDC (--provenance); do not set an emptyNPM_TOKENsecret (it breaks OIDC auth).
Merges without a version bump are no-ops: the workflow skips publish when the version already exists on npm.
| Issue | Fix |
|---|---|
Could not load the shared scheme for CodeReloadExample |
Use --scheme CodeReloadFreshRN |
| Pods path errors after moving the repo | cd example/ios && rm -rf Pods build && pod install |
| Metro port in use | Stop the other process on :8081 or run npx react-native start --port 8082 |
| Stale on-device files | Reinstall the app or tap Replace when prompted |