eru-devtools-sdk
v0.1.0
Published
Lightweight SDK that connects apps to Eru Dev Tools for real-time console logs and network inspection
Maintainers
Readme
@eru/devtools-sdk
Lightweight SDK that connects your app to Eru Dev Tools for real-time console log and network request inspection. Works with React Native, Web, and Node.js.
Think Reactotron / Flipper, but built into Eru so you get proxy capture + SDK capture + API testing in one tool.
Install
npm install @eru/devtools-sdk
# or
yarn add @eru/devtools-sdk
# or
pnpm add @eru/devtools-sdkQuick Start
import { EruDevTools } from '@eru/devtools-sdk';
if (__DEV__) {
EruDevTools.connect({
host: 'localhost',
port: 9091,
appName: 'MyApp',
});
}That's it. All console.log/warn/error/debug/info calls and all fetch() / XMLHttpRequest traffic will stream to Eru in real time.
Platform Setup
React Native
// index.js — add after any XMLHttpRequest polyfill overrides
import { EruDevTools } from '@eru/devtools-sdk';
if (__DEV__) {
EruDevTools.connect({
host: 'localhost',
port: 9091,
appName: 'MyApp',
platform: 'react-native',
});
}iOS Simulator — localhost works out of the box.
Android Emulator — run adb reverse tcp:9091 tcp:9091 first, then localhost works.
Physical Device — use your machine's local IP (e.g. 192.168.1.42) instead of localhost.
Web (React, Vue, Svelte, etc.)
// main.ts or index.ts
import { EruDevTools } from '@eru/devtools-sdk';
if (import.meta.env.DEV) {
EruDevTools.connect({
host: 'localhost',
port: 9091,
appName: 'MyWebApp',
platform: 'web',
});
}Node.js
import { EruDevTools } from '@eru/devtools-sdk';
if (process.env.NODE_ENV !== 'production') {
EruDevTools.connect({
host: 'localhost',
port: 9091,
appName: 'MyServer',
platform: 'node',
interceptConsole: true,
interceptNetwork: false, // Node's fetch differs from browser
});
}API
EruDevTools.connect(options)
Connect to Eru's DevTools server and start intercepting.
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| host | string | 'localhost' | Eru DevTools server host |
| port | number | 9091 | Eru DevTools server port |
| appName | string | 'App' | Display name in Eru |
| appVersion | string | '' | App version shown in connection info |
| platform | string | auto-detected | 'react-native', 'web', 'ios', 'android', 'node' |
| deviceName | string | '' | Device name (e.g. "iPhone 15 Pro") |
| bundleId | string | '' | Bundle identifier |
| interceptConsole | boolean | true | Auto-patch console.log/warn/error/debug/info |
| interceptNetwork | boolean | true | Auto-patch fetch() and XMLHttpRequest |
EruDevTools.disconnect()
Disconnect and restore original console and fetch / XMLHttpRequest methods.
EruDevTools.log(message, ...args)
Send a manual log entry.
EruDevTools.warn(message, ...args)
Send a manual warning.
EruDevTools.error(message, ...args)
Send a manual error.
EruDevTools.debug(message, ...args)
Send a manual debug log.
EruDevTools.tagged(tag, message, ...args)
Send a log with a category tag. Tags appear as colored badges in Eru's console.
EruDevTools.tagged('auth', 'Token refreshed', { expiresIn: 3600 });
EruDevTools.tagged('navigation', 'Screen changed', { screen: 'Profile' });
EruDevTools.tagged('redux', 'Action dispatched', action);EruDevTools.isConnected
Returns true if currently connected to the Eru server.
What Gets Captured
Console (automatic)
console.log(),console.warn(),console.error(),console.debug(),console.info()- Original console methods are always called first — output is never suppressed
- Arguments are safely serialized (handles circular refs, Error objects, DOM nodes)
- Individual args truncated at 10KB
Network (automatic)
- All
fetch()requests and responses - All
XMLHttpRequesttraffic (React Native uses this under the hood) - Captured: method, URL, headers, body, status code, duration
- Bodies truncated at 100KB
- Does not interfere with your app's network behavior
Auto-Reconnect
The SDK automatically reconnects with exponential backoff (1s → 30s) if the connection drops. Logs and network events are queued (up to 500 messages) while disconnected and flushed when reconnected.
Size
< 5KB minified + gzipped. Zero dependencies.
License
MIT
