Set up your app
For AI agents: this page is Markdown at https://squiggle.sh/docs/setup.md. Every docs page is listed at https://squiggle.sh/llms.txt, and all of them are one file at https://squiggle.sh/llms-full.txt.
Add Squiggle to a React Native app and check that it works. Most of the time goes on one native rebuild.
A React web app needs none of this: a flow, Studio or your agent opens it in Squiggle’s window with nothing added to your project. In a Vite or Next.js app, squiggle init declares the app and sets up the rest, for a browser Squiggle didn’t open. See Set it up with squiggle init.
Before you start
- An Apple Silicon Mac with macOS 15 or later.
- Xcode, with a working iOS simulator (
xcrun simctlruns). - React Native 0.76 or later and React 18.3 or later, in an app you can rebuild: an Expo development build or a bare React Native app. Expo Go can’t load the SDK, because it includes native code.
To run Squiggle in a Niteshift task instead of on your Mac, set up the SDK the same way, then see Niteshift tasks.
Set it up
Install Squiggle
Studio, the app you download, includes thesquigglecommand: open Settings and press Install next to Command line. To use only the terminal, install it from npm. Then start the trial: 14 days, every feature, no card.npm install -g @squiggle.sh/clisquiggle activate --trialSet up your app
Run this in your app’s folder. It adds the SDK and the Babel plugin, loads Squiggle before React, and offers to connect the coding agents it finds: Claude Code, Copilot, Codex and Cursor. It lists every change and asks before writing anything.squiggle initTrack your screens
The one editinitleaves to you, because it is your own component. Wrap your root so Squiggle knows which screen is showing: waiting for a screen, checking it, and the Screen map all need it. With React Navigation, pass yourNavigationContainerref.import { Squiggle } from '@squiggle.sh/react-native';import { Stack, useNavigationContainerRef } from 'expo-router';export default function RootLayout() { return ( <Squiggle navigationRef={useNavigationContainerRef()}> <Stack /> </Squiggle> );}Rebuild once
The SDK includes native code, so a reload is not enough. A debug build on the simulator starts Squiggle inside your app however you launch it: from this command, Xcode or its icon. Bare React Native:npx react-native run-ios.npx expo run:iosCheck the setup
doctorchecks the simulator, the app, screen tracking, source lines and your licence, and tells you how to fix anything that is missing.squiggle doctorRun your first flow
smokeis the flowinitwrote: it checks the app starts. Then record a journey of your own: use the app, press Ctrl-C to stop, and Squiggle drafts the flow from the recording.squiggle flow smokesquiggle record loginsquiggle flow --from-recording .squiggle/recordings/login.sqrec -o .squiggle/flows/login.yaml
Squiggle runs inside your app only on the simulator: in a debug build, or in a release build you keep it in. A build for a device never contains it.
Your first flow run also watches the app for a few seconds before it starts and keeps what it saw as a performance baseline named first, to compare a later change with. See The first baseline is automatic.
What init changes
squiggle init lists each change and asks before writing anything. squiggle init --dry-run prints the list and writes nothing. Running it again later changes nothing that is already done.
| File | What init does |
|---|---|
package.json | Adds @squiggle.sh/react-native at the CLI’s own version, and react-native-nitro-modules at the newest version your React Native builds with, using your package manager. It leaves your scripts as they are. |
babel.config.js | Adds the Babel plugin, @squiggle.sh/react-native/babel. In an Expo app with no Babel config, it creates the file. |
metro.config.js | Wraps your Metro config in withSquiggle, so the report card can say which modules your app evaluates at startup. In an Expo app with no Metro config, it creates the file. |
index.js | Puts the SDK import on the first line of your entry file. An Expo Router app gets a new index.js, and "main" points at it. |
.squiggle/flows/smoke.yaml | A first flow, smoke, that waits for the app to settle and checks the screen isn’t blank. |
.squiggle/config.jsonc | Records your app’s bundle id for each platform it builds for under apps, when it can read it from app.json or the Xcode project. Adds default performance budgets for every screen under "*", for you to tighten. See Set a budget per screen. With --pr-evidence it also lets your agent put screenshots and recordings on your pull requests; see Show your work on the pull request. |
.squiggle/.gitignore | Keeps the project folder out of git, except your flows, your declared interfaces (interfaces/) and config.jsonc. |
.github/workflows/squiggle.yml | Only in a git repository, and only if the file doesn’t exist: a pull request check that fails when your iOS bundle grows past its allowance. It builds the bundle with npx expo export, so in an app without Expo, change those steps to your own bundle command. See Run in CI. |
~/.squiggle/agent | Copies Squiggle’s agent here, where a debug build of your app loads it however you start it. Every later run keeps it current. |
.mcp.json | When you say yes to connecting your coding agents: registers the MCP server for Claude Code, and installs the agent kit in .claude/. Copilot uses .vscode/mcp.json, Codex ~/.codex/config.toml and Cursor .cursor/mcp.json. See Connect your agent. |
init merges into files that already exist. It never replaces your .mcp.json or the other servers in it.
In a monorepo, run squiggle init in your app’s folder. It edits the app’s own files there and writes .squiggle/ at the repository root, so every app in the repository shares one project. If the app already has its own .squiggle folder with a config.jsonc or flows, init writes there instead, and every squiggle command and the MCP server run in that app’s folder use it. When it is the only app in apps or packages with its own .squiggle, and the repository root has none, they use it from the repository root too, and init run at the root sets up that app and registers your coding agents at the root, where you open them. See How Squiggle finds the folder.
Give the project a simulator of its own
When no booted simulator is free for your app, because none is booted or another project’s Squiggle session is driving the app on each one, init offers to create a simulator for this project. It’s named after your package and the newest iOS version’s current iPhone, such as checkout iPhone 17 Pro. If you say yes, init creates it, boots it and records its UDID as udid in .squiggle/config.local.jsonc, the project’s settings for this Mac only, which stay out of git. Every squiggle command, your agent and Studio then use that simulator, and the rebuild step init prints installs your app there. If the simulator already exists from an earlier run and is shut down, init boots it instead of creating another.
A simulator takes several gigabytes and a minute or more to boot, so --yes doesn’t create one. To create it without the question, in a script or from your agent, add --create-simulator. squiggle init --dry-run --create-simulator shows the simulator it would create. Without a terminal and without the flag, init creates nothing; when no simulator is free, it prints the squiggle init --create-simulator command that creates one, so your agent learns it during setup.
If the project’s config already names a simulator, or SQUIGGLE_UDID is set, init doesn’t offer one. To create or start a simulator later, use squiggle device simulator create or squiggle device simulator boot. See Settings for this Mac only.
If init can’t make a change
When init doesn’t recognise a file, it leaves it alone and prints a to-do instead. These are the edits it would have made.
Load the SDK first
The SDK import must be the first line of your app’s entry file, before anything loads React. Otherwise Squiggle misses the screens your app renders at startup. If package.json has "main": "expo-router/entry", create an index.js like this and set "main" to "index.js":
// index.js: the SDK first, then your app's usual entryimport '@squiggle.sh/react-native';import 'expo-router/entry';Add the Babel plugin
The plugin gives each component its file and line, so the Inspector can open your editor at the right place. It also records reads and writes for MMKV, AsyncStorage, SQLite and Legend State. Keep babel-preset-expo as the only preset:
module.exports = function (api) { api.cache(true); return { presets: ['babel-preset-expo'], plugins: ['@squiggle.sh/react-native/babel'], };};A config that names @squiggle.sh/babel-plugin, the plugin’s package up to version 0.3, keeps working. Replace it with @squiggle.sh/react-native/babel and remove that package, so the plugin is always the same version as the SDK.
Wrap your Metro config
withSquiggle times each module your app evaluates while it starts, in a development build. The report card uses it to name the screens your app loads at startup though it doesn’t open on them. It changes nothing in a production build. Wrap whatever your config exports:
const { getDefaultConfig } = require('expo/metro-config');const { withSquiggle } = require('@squiggle.sh/react-native/metro');const config = getDefaultConfig(__dirname);module.exports = withSquiggle(config);In a bare React Native app, wrap the config mergeConfig returns. withSquiggle works with other wrappers such as withNativeWind, in either order. Without it, the report card’s startup row reports “not measured”, and so can the cold-start phase budgets.
It also ties Metro’s cache to the Babel plugin. After you upgrade @squiggle.sh/react-native, restart Metro and every file is transformed again with the new plugin; you don’t need --clear.
After you update Squiggle
After you update the squiggle command, you don’t need to rebuild the app. The next command that launches or checks it, such as squiggle flow or squiggle doctor, brings its copy of Squiggle up to date, and every launch after that loads the new one. An app still running the old copy is relaunched by squiggle flow, and squiggle doctor says so.
After you upgrade @squiggle.sh/react-native, rebuild the app once: the SDK includes native code.
What ships in your release build
Nothing from Squiggle. A release build of your app has no Squiggle code: no SDK, nothing from the Babel plugin, and no native library. You don’t change your app for it. The calls you make into Squiggle still work and do nothing: <Squiggle> renders your app, defineAction runs your function, useTunable returns its default, and logEvent still prints its line.
A release build is one whose JavaScript is bundled for production: a Release build from Xcode, a release build from Gradle, an EAS production build or expo export. The native library links into the Debug configuration and the debug build type only, so a configuration of your own, such as Staging, doesn’t get it.
This relies on the Babel plugin, which squiggle init adds. Without the plugin, a release build carries the whole SDK; it still sends nothing anywhere.
Keep Squiggle in release builds
To drive or measure a release build of your app with Squiggle, keep Squiggle in it:
Add release to your config
In
.squiggle/config.jsoncat your project’s root. In a monorepo, that’s the one in your app’s folder if it has one, else the one at the repository root. An app without its own config never uses another app’s, so each app opts in for itself. See How Squiggle finds the folder.{ "release": true}Link the native library into Release
Run
pod installinios/.expo run:iosand EAS Build run it for you when they build. Run it again whenever you turnreleaseon or off: a Release build linked before you turned it on connects but can’t say which app it is, so Squiggle saves nothing from it.Rebuild
Restart Metro and build the app again. If your Metro config isn’t wrapped in
withSquiggle, start Metro with--clear.
A release build that keeps Squiggle still connects only when you build it with EXPO_PUBLIC_SQUIGGLE_ALLOW_RELEASE=1, and then only to the same Mac; EXPO_PUBLIC_SQUIGGLE_ALLOW_REMOTE=1 allows other addresses.
When a release build leaves Squiggle out, Metro prints a warning once that names the config file it read. If you meant to keep Squiggle, add "release": true to that file. If your app’s folder has a .squiggle/config.jsonc that turns release on, the warning names it: move its settings to the one at the root.
React web apps
A production build of a React web app gets the same kind of stand-in for @squiggle.sh/react when it is built with Vite, webpack, Rspack or Next.js, or with Squiggle’s esbuild or Bun plugin. There is nothing to turn on, and nothing to keep: squiggle up --url 4173 --production drives a production build because it loads Squiggle into the tab itself. With another bundler, add production to its export conditions.