SDK
The public API of @parallax-rn/sdk, the dev-only code that runs inside your React Native app.
@parallax-rn/sdk is the dev-only code that runs inside your app. It captures console output, uncaught errors and network requests, and lets you register things the agent can read or run. Importing it has no side effects.
Start it
if (__DEV__) {
require('@parallax-rn/sdk').start();
}Metro removes the whole branch from a release bundle. As a second guard, start() does nothing and returns false when __DEV__ is false.
Functions
| Export | What it does |
|---|---|
start(): boolean | Starts capturing console output (debug, log, info, warn, error), uncaught errors and network requests. Returns false and does nothing when __DEV__ is false. Calling it again is harmless. |
stop(): void | Stops capturing and restores the console methods and the error handler. |
isStarted(): boolean | Whether the SDK is capturing. |
registerCommand(name, handler, meta?) | Registers a command the agent can list and run with app_commands and app_command_run. Registering a name again replaces it (Fast Refresh re-runs modules). Returns a function that unregisters it. |
registerNavigation(ref) | Follows a React Navigation container ref (createNavigationContainerRef(), or Expo Router's useNavigationContainerRef()), so the agent can read the current route and its history. Returns a stop function. |
registerStore(name, store, options?) | Follows a Redux or Zustand store (anything with getState() and subscribe()) as the state source state:<name>. Returns an unregister function. |
registerQueryClient(name, client) | Follows a TanStack Query client as the source query:<name>. Returns an unregister function. |
createSdk(options?) | Creates a separate SDK instance. Options: limits (a partial SdkLimits) and network (capture HTTP requests, default true). You rarely need it. |
registerCommand takes meta with an optional description and an optional argsHint, a short human-readable description of the arguments such as { id: string }. A command handler may be async; its result must be JSON-serializable. Parallax also has a built-in parallax.ping command.
registerStore takes { actions: true } to also record the type of the last Redux action. It is off by default because it wraps the store's dispatch.
import { registerCommand, registerNavigation, registerStore } from '@parallax-rn/sdk';
if (__DEV__) {
registerCommand('resetOnboarding', () => resetOnboarding(), { description: 'Show onboarding again' });
registerNavigation(navigationRef);
registerStore('app', store, { actions: true });
}Secrets are removed from what the agent receives (keys and values that look like credentials), and snapshots are size-bounded.
Types and constants
Sdk, SdkOptions, CommandHandler, CommandMeta, NavigationRefLike, StoreOptions, SdkLimits, the DEFAULT_LIMITS object and SDK_VERSION.
What it keeps
The original console methods and the previous error handler always run first, so LogBox, Metro logs and the DevTools console behave as without the SDK; the red box still appears. Logs and errors go into ring buffers, so an agent that connects late or after a reload still reads the history. Defaults in DEFAULT_LIMITS:
| Limit | Default |
|---|---|
| Log entries kept | 1000 |
| Error entries kept | 100 |
| Network requests kept | 300 |
| Navigation transitions kept | 100 |
| Snapshots kept per store | 50 |
| Characters per log message / per stack | 4000 / 8000 (a cut entry is marked truncated) |
| Characters per request or response body | 32000 |
The agent receives less than this: tool answers are cut to keep them cheap for the model.