Quick Start¶
This guide walks through peekr's three modes with real examples. Each section is self-contained — pick the mode that fits your workflow.
Mode 1: Proxy mode¶
What it does: Starts a local HTTP proxy. You point your app's base URL at the proxy, and peekr logs + forwards every request to the real upstream.
When to use it: Quick one-off inspection when you can easily change a base URL environment variable.
Step by step¶
1. Start the proxy:
peekr listens on http://localhost:49999 and forwards to https://jsonplaceholder.typicode.com.
2. Send a request through the proxy:
3. Check the terminal. You'll see the full request/response logged:
================================================================================
[#1] GET /todos/1
================================================================================
--- Response 200 ---
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
================================================================================
4. Integrate with your app by changing the base URL:
Start your app normally — all requests to the configured base URL now flow through peekr.
Tip
Use --no-forward to capture requests without forwarding them. Combine with --mock '{"status":"ok"}' to return custom responses.
Mode 2: Run mode¶
What it does: Spawns your application as a child process and monkey-patches node:http and node:https so all outgoing HTTP/HTTPS calls are automatically intercepted. No .env changes needed.
When to use it: You want to see every outgoing call your app makes without touching any configuration.
Step by step¶
1. Run your app through peekr:
Or with npm scripts:
2. Trigger some traffic. Use your app normally — make API calls, hit endpoints, whatever generates outgoing HTTP traffic.
3. Watch the terminal. Every outgoing request is logged automatically:
================================================================================
[#1] POST /api/v1/users
→ api.example.com
================================================================================
--- Payload ---
{ "email": "user@example.com", "name": "Jane" }
--- Response 201 ---
{ "id": 42, "email": "user@example.com" }
================================================================================
Your app's stdout and stderr are also shown, so you get a unified view of logs + HTTP traffic.
4. Filter by host if your app talks to multiple services:
Only requests to api.example.com are logged; everything else passes through untouched.
How it works
peekr writes a tiny loader to /tmp and injects it via NODE_OPTIONS=--import on Node 18.19+ / 20+, or NODE_OPTIONS=--require on older Node 18 releases. This patches Node's HTTP stack in the child process.
Mode 3: UI mode¶
What it does: Launches a browser-based dashboard that shows both incoming and outgoing HTTP traffic in real time. Incoming traffic is captured via a reverse proxy in front of your app.
When to use it: You want a visual overview of all traffic flowing through your application, or you need to inspect both directions.
Traffic flow¶
External client → reverse proxy (:49998) → your app (:3000)
↓ outgoing
peekr proxy (:49999) → real upstream
↓
dashboard (:49997)
Step by step¶
1. Start peekr with the dashboard:
This starts your app, the reverse proxy, and the dashboard.
2. Open the dashboard at http://localhost:49997.
3. Send incoming traffic to the reverse proxy instead of your app directly:
4. Watch the dashboard. Each request appears as a card showing:
- Direction: IN (incoming) or OUT (outgoing)
- Method, host, path, and status code
- Collapsible headers and body details
- Timing information
5. If your app is already running separately, you can attach just the dashboard:
Note: in this mode, only incoming traffic is captured. To capture outgoing traffic too, start your app through peekr using --.
Tip
The dashboard uses Server-Sent Events (SSE) for real-time updates — no polling, no WebSocket setup.
Custom ports¶
Use flags for one-off changes:
Or put the ports in peekr.config.json:
Then run:
Flags override values from the config file.
Choosing the right mode¶
| Scenario | Recommended mode |
|---|---|
| Quick check of a specific API call | Proxy — start proxy, curl through it |
| Debug all outgoing calls from your app | Run — automatic interception, no config |
| Full traffic overview in a browser | UI — both directions, visual dashboard |
| CI/testing with captured traffic | Run with --log-file for persistent logs |
| Demo or pair programming | UI — easy to share a screen with the dashboard |
Next steps¶
- Learn about the Rules Engine to block or mock requests dynamically
- Explore the Dashboard UI features in detail
- See the full CLI Reference for all options and flags