agent-react-devtools 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +21 -2
- package/package.json +2 -1
- package/skills/react-devtools/SKILL.md +140 -0
- package/skills/react-devtools/references/commands.md +82 -0
- package/skills/react-devtools/references/profiling-guide.md +110 -0
- package/skills/react-devtools/references/setup.md +100 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -198,9 +198,28 @@ For Expo, the connection works automatically with the Expo dev client.
|
|
|
198
198
|
|
|
199
199
|
To use a custom port, set the `REACT_DEVTOOLS_PORT` environment variable.
|
|
200
200
|
|
|
201
|
-
## Using with AI
|
|
201
|
+
## Using with AI Coding Assistants
|
|
202
202
|
|
|
203
|
-
Add
|
|
203
|
+
Add the skill to your AI coding assistant for richer context:
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
npx skills add piotrski/agent-react-devtools
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
This works with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Goose, OpenCode, and Windsurf.
|
|
210
|
+
|
|
211
|
+
### Claude Code plugin
|
|
212
|
+
|
|
213
|
+
You can also install via the Claude Code plugin marketplace:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
/plugin marketplace add piotrski/agent-react-devtools
|
|
217
|
+
/plugin install agent-react-devtools@piotrski
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Manual setup
|
|
221
|
+
|
|
222
|
+
Alternatively, add something like this to your project's `CLAUDE.md` (or equivalent agent instructions):
|
|
204
223
|
|
|
205
224
|
```markdown
|
|
206
225
|
## React Debugging
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-react-devtools",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "CLI tool for AI agents to inspect React component trees and profile performance",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|
|
22
|
+
"skills",
|
|
22
23
|
"README.md",
|
|
23
24
|
"CHANGELOG.md"
|
|
24
25
|
],
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-devtools
|
|
3
|
+
description: React DevTools CLI for AI agents. Use when the user asks you to debug a React or React Native app at runtime, inspect component props/state/hooks, diagnose render performance, profile re-renders, find slow components, or understand why something re-renders. Triggers include "why does this re-render", "inspect the component", "what props does X have", "profile the app", "find slow components", "debug the UI", "check component state", "the app feels slow", or any React runtime debugging task.
|
|
4
|
+
allowed-tools: Bash(agent-react-devtools:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# agent-react-devtools
|
|
8
|
+
|
|
9
|
+
CLI that connects to a running React or React Native app via the React DevTools protocol and exposes the component tree, props, state, hooks, and profiling data in a token-efficient format.
|
|
10
|
+
|
|
11
|
+
## Core Workflow
|
|
12
|
+
|
|
13
|
+
1. **Ensure connection** — check `agent-react-devtools status`. If the daemon is not running, start it with `agent-react-devtools start`.
|
|
14
|
+
2. **Inspect** — get the component tree, search for components, inspect props/state/hooks.
|
|
15
|
+
3. **Profile** — start profiling, trigger the interaction (or ask the user to), stop profiling, analyze results.
|
|
16
|
+
4. **Act** — use the data to fix the bug, optimize performance, or explain what's happening.
|
|
17
|
+
|
|
18
|
+
## Essential Commands
|
|
19
|
+
|
|
20
|
+
### Daemon
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
agent-react-devtools start # Start daemon (auto-starts on first command)
|
|
24
|
+
agent-react-devtools stop # Stop daemon
|
|
25
|
+
agent-react-devtools status # Check connection: port, connected apps, component count
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Component Inspection
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
agent-react-devtools get tree # Full component hierarchy (labels: @c1, @c2, ...)
|
|
32
|
+
agent-react-devtools get tree --depth 3 # Limit depth
|
|
33
|
+
agent-react-devtools get component @c5 # Props, state, hooks for a specific component
|
|
34
|
+
agent-react-devtools find Button # Search by display name (fuzzy)
|
|
35
|
+
agent-react-devtools find Button --exact # Exact match
|
|
36
|
+
agent-react-devtools count # Count by type: fn, cls, host, memo, ...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Performance Profiling
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
agent-react-devtools profile start # Start recording
|
|
43
|
+
agent-react-devtools profile stop # Stop and collect data
|
|
44
|
+
agent-react-devtools profile slow # Slowest components by avg render time
|
|
45
|
+
agent-react-devtools profile slow --limit 10 # Top 10
|
|
46
|
+
agent-react-devtools profile rerenders # Most re-rendered components
|
|
47
|
+
agent-react-devtools profile report @c5 # Detailed report for one component
|
|
48
|
+
agent-react-devtools profile timeline # Chronological commit list
|
|
49
|
+
agent-react-devtools profile commit 3 # Detail for commit #3
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Understanding the Output
|
|
53
|
+
|
|
54
|
+
### Component Labels
|
|
55
|
+
|
|
56
|
+
Every component gets a stable label like `@c1`, `@c2`. Use these to reference components in follow-up commands:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
@c1 [fn] "App"
|
|
60
|
+
├─ @c2 [fn] "Header"
|
|
61
|
+
├─ @c3 [fn] "TodoList"
|
|
62
|
+
│ ├─ @c4 [fn] "TodoItem" key="1"
|
|
63
|
+
│ └─ @c5 [fn] "TodoItem" key="2"
|
|
64
|
+
└─ @c6 [host] "div"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Type abbreviations: `fn` = function, `cls` = class, `host` = DOM element, `memo` = React.memo, `fRef` = forwardRef, `susp` = Suspense, `ctx` = context.
|
|
68
|
+
|
|
69
|
+
### Inspected Component
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
@c3 [fn] "TodoList"
|
|
73
|
+
props:
|
|
74
|
+
items: [{"id":1,"text":"Buy milk"},{"id":2,"text":"Walk dog"}]
|
|
75
|
+
onDelete: ƒ
|
|
76
|
+
state:
|
|
77
|
+
filter: "all"
|
|
78
|
+
hooks:
|
|
79
|
+
useState: "all"
|
|
80
|
+
useMemo: [...]
|
|
81
|
+
useCallback: ƒ
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`ƒ` = function value. Values over 60 chars are truncated.
|
|
85
|
+
|
|
86
|
+
### Profiling Output
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Slowest (by avg render time):
|
|
90
|
+
ExpensiveList avg:12.3ms max:18.1ms renders:47 cause:props-changed
|
|
91
|
+
TodoItem avg:2.1ms max:5.0ms renders:94 cause:parent-rendered
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Render causes: `props-changed`, `state-changed`, `hooks-changed`, `parent-rendered`, `force-update`, `first-mount`.
|
|
95
|
+
|
|
96
|
+
## Common Patterns
|
|
97
|
+
|
|
98
|
+
### Diagnose slow interactions
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
agent-react-devtools profile start
|
|
102
|
+
# User interacts with the app (or use agent-browser to drive the UI)
|
|
103
|
+
agent-react-devtools profile stop
|
|
104
|
+
agent-react-devtools profile slow --limit 5
|
|
105
|
+
agent-react-devtools profile rerenders --limit 5
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Then inspect the worst offenders with `get component @cN` and `profile report @cN`.
|
|
109
|
+
|
|
110
|
+
### Find a component and check its state
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
agent-react-devtools find SearchBar
|
|
114
|
+
agent-react-devtools get component @c12
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Verify a fix worked
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
agent-react-devtools profile start
|
|
121
|
+
# Repeat the interaction
|
|
122
|
+
agent-react-devtools profile stop
|
|
123
|
+
agent-react-devtools profile slow --limit 5
|
|
124
|
+
# Compare render counts and durations to the previous run
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Important Rules
|
|
128
|
+
|
|
129
|
+
- **Labels reset** when the app reloads or components unmount/remount. Always re-check with `get tree` or `find` after a page reload.
|
|
130
|
+
- **`status` first** — if status shows 0 connected apps, the React app is not connected. The user may need to run `npx agent-react-devtools init` in their project first.
|
|
131
|
+
- **Profile while interacting** — profiling only captures renders that happen between `profile start` and `profile stop`. Make sure the relevant interaction happens during that window.
|
|
132
|
+
- **Use `--depth`** on large trees — a deep tree can produce a lot of output. Start with `--depth 3` or `--depth 4` and go deeper only on the subtree you care about.
|
|
133
|
+
|
|
134
|
+
## References
|
|
135
|
+
|
|
136
|
+
| File | When to read |
|
|
137
|
+
|------|-------------|
|
|
138
|
+
| [commands.md](references/commands.md) | Full command reference with all flags and edge cases |
|
|
139
|
+
| [profiling-guide.md](references/profiling-guide.md) | Step-by-step profiling workflows and interpreting results |
|
|
140
|
+
| [setup.md](references/setup.md) | How to connect different frameworks (Vite, Next.js, Expo, CRA) |
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Command Reference
|
|
2
|
+
|
|
3
|
+
## Daemon Management
|
|
4
|
+
|
|
5
|
+
### `agent-react-devtools start [--port N]`
|
|
6
|
+
Start the background daemon. Default port: 8097. The daemon listens for WebSocket connections from React apps and IPC connections from the CLI. Auto-starts when you run any other command, so you rarely need this explicitly.
|
|
7
|
+
|
|
8
|
+
### `agent-react-devtools stop`
|
|
9
|
+
Stop the daemon process. All connection state is lost.
|
|
10
|
+
|
|
11
|
+
### `agent-react-devtools status`
|
|
12
|
+
Show daemon status: port, connected apps, component count, profiling state, uptime.
|
|
13
|
+
|
|
14
|
+
Output:
|
|
15
|
+
```
|
|
16
|
+
Daemon: running (port 8097)
|
|
17
|
+
Apps: 1 connected, 42 components
|
|
18
|
+
Uptime: 120s
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If profiling is active, shows `Profiling: active`.
|
|
22
|
+
|
|
23
|
+
## Component Inspection
|
|
24
|
+
|
|
25
|
+
### `agent-react-devtools get tree [--depth N]`
|
|
26
|
+
Print the component hierarchy as an indented tree. Each node shows:
|
|
27
|
+
- Label (`@c1`, `@c2`, ...) — stable within a session, resets on app reload
|
|
28
|
+
- Type tag (`fn`, `cls`, `host`, `memo`, `fRef`, `susp`, `ctx`)
|
|
29
|
+
- Display name
|
|
30
|
+
- Key (if present)
|
|
31
|
+
|
|
32
|
+
Use `--depth N` to limit tree depth. Recommended for large apps.
|
|
33
|
+
|
|
34
|
+
### `agent-react-devtools get component <@cN | id>`
|
|
35
|
+
Inspect a single component. Shows:
|
|
36
|
+
- **props** — all prop values (functions shown as `ƒ`, long values truncated at 60 chars)
|
|
37
|
+
- **state** — state values (class components and useState)
|
|
38
|
+
- **hooks** — all hooks with current values and sub-hooks
|
|
39
|
+
|
|
40
|
+
Accepts a label (`@c5`) or numeric React fiber ID.
|
|
41
|
+
|
|
42
|
+
### `agent-react-devtools find <name> [--exact]`
|
|
43
|
+
Search components by display name. Default is case-insensitive substring match. Use `--exact` for exact match.
|
|
44
|
+
|
|
45
|
+
Returns a flat list of matching components with labels, types, and keys.
|
|
46
|
+
|
|
47
|
+
### `agent-react-devtools count`
|
|
48
|
+
Count components by type. Output: `42 components (fn:25 host:12 memo:3 cls:2)`.
|
|
49
|
+
|
|
50
|
+
## Profiling
|
|
51
|
+
|
|
52
|
+
### `agent-react-devtools profile start [name]`
|
|
53
|
+
Start a profiling session. Optional name for identification. Only one session can be active at a time.
|
|
54
|
+
|
|
55
|
+
### `agent-react-devtools profile stop`
|
|
56
|
+
Stop profiling and collect data from React. Shows a summary with duration, commit count, and top rendered components.
|
|
57
|
+
|
|
58
|
+
### `agent-react-devtools profile slow [--limit N]`
|
|
59
|
+
Rank components by average render duration (slowest first). Default limit: 10.
|
|
60
|
+
|
|
61
|
+
Output columns: component name, avg duration, max duration, render count, primary cause.
|
|
62
|
+
|
|
63
|
+
### `agent-react-devtools profile rerenders [--limit N]`
|
|
64
|
+
Rank components by render count (most re-renders first). Default limit: 10.
|
|
65
|
+
|
|
66
|
+
Output columns: component name, render count, primary cause.
|
|
67
|
+
|
|
68
|
+
### `agent-react-devtools profile report <@cN | id>`
|
|
69
|
+
Detailed render report for a single component: render count, avg/max/total duration, all render causes.
|
|
70
|
+
|
|
71
|
+
### `agent-react-devtools profile timeline [--limit N]`
|
|
72
|
+
Chronological list of React commits during the profiling session. Each entry: index, duration, component count.
|
|
73
|
+
|
|
74
|
+
### `agent-react-devtools profile commit <N | #N> [--limit N]`
|
|
75
|
+
Detail for a specific commit by index. Shows per-component self/total duration and render causes.
|
|
76
|
+
|
|
77
|
+
## Setup
|
|
78
|
+
|
|
79
|
+
### `agent-react-devtools init [--dry-run]`
|
|
80
|
+
Auto-detect the framework in the current directory and configure the devtools connection. Supports Vite, Next.js, CRA, and Expo/React Native.
|
|
81
|
+
|
|
82
|
+
Use `--dry-run` to preview changes without writing files.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Profiling Guide
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
agent-react-devtools profile start
|
|
7
|
+
# Trigger the slow interaction (type, click, navigate)
|
|
8
|
+
agent-react-devtools profile stop
|
|
9
|
+
agent-react-devtools profile slow --limit 5
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Step-by-Step Workflow
|
|
13
|
+
|
|
14
|
+
### 1. Establish a Baseline
|
|
15
|
+
|
|
16
|
+
Before profiling, check the current state:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
agent-react-devtools status # Confirm app is connected
|
|
20
|
+
agent-react-devtools count # How many components are mounted
|
|
21
|
+
agent-react-devtools get tree --depth 3 # Understand the structure
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Profile the Interaction
|
|
25
|
+
|
|
26
|
+
Start profiling, then trigger the specific interaction the user reports as slow:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
agent-react-devtools profile start "typing in search"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The user should perform the interaction now. If using agent-browser, you can drive the interaction programmatically.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
agent-react-devtools profile stop
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. Identify Bottlenecks
|
|
39
|
+
|
|
40
|
+
**Slowest components** — which components take the most time per render:
|
|
41
|
+
```bash
|
|
42
|
+
agent-react-devtools profile slow --limit 5
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Most re-rendered** — which components render too often:
|
|
46
|
+
```bash
|
|
47
|
+
agent-react-devtools profile rerenders --limit 5
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
These two views complement each other:
|
|
51
|
+
- A component that renders 100 times at 0.1ms each = 10ms total (re-render problem)
|
|
52
|
+
- A component that renders 2 times at 50ms each = 100ms total (slow render problem)
|
|
53
|
+
|
|
54
|
+
### 4. Drill Into Specific Components
|
|
55
|
+
|
|
56
|
+
Once you identify a suspect, get its full render report:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
agent-react-devtools profile report @c12
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This shows all render causes. Common patterns:
|
|
63
|
+
|
|
64
|
+
| Cause | Meaning | Typical Fix |
|
|
65
|
+
|-------|---------|-------------|
|
|
66
|
+
| `parent-rendered` | Parent re-rendered, child has no bailout | Wrap child in `React.memo()` |
|
|
67
|
+
| `props-changed` | Received new prop references | Stabilize with `useMemo`/`useCallback` in parent |
|
|
68
|
+
| `state-changed` | Component's own state changed | Check if state update is necessary |
|
|
69
|
+
| `hooks-changed` | A hook dependency changed | Review hook dependencies |
|
|
70
|
+
| `first-mount` | Initial render | Normal — not a problem |
|
|
71
|
+
|
|
72
|
+
### 5. Inspect the Component
|
|
73
|
+
|
|
74
|
+
Read the component's current props and hooks to understand what's changing:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
agent-react-devtools get component @c12
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Look for:
|
|
81
|
+
- Function props (`ƒ`) — likely unstable references if not wrapped in `useCallback`
|
|
82
|
+
- Object/array props — likely new references if not wrapped in `useMemo`
|
|
83
|
+
- State that updates too frequently
|
|
84
|
+
|
|
85
|
+
### 6. Fix and Verify
|
|
86
|
+
|
|
87
|
+
After applying the fix, re-profile with the same interaction:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
agent-react-devtools profile start "after fix"
|
|
91
|
+
# Same interaction
|
|
92
|
+
agent-react-devtools profile stop
|
|
93
|
+
agent-react-devtools profile slow --limit 5
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Compare render counts and durations to confirm improvement.
|
|
97
|
+
|
|
98
|
+
## Common Performance Issues
|
|
99
|
+
|
|
100
|
+
### Cascading re-renders from context or lifted state
|
|
101
|
+
A parent component re-renders (e.g., from a timer or context change) and all children re-render because none use `React.memo`. Look for high re-render counts with `parent-rendered` cause.
|
|
102
|
+
|
|
103
|
+
### Unstable prop references
|
|
104
|
+
Parent passes `onClick={() => ...}` or `style={{...}}` inline — creates new references every render, defeating `memo()`. The child shows `props-changed` as the cause even though the values are semantically identical.
|
|
105
|
+
|
|
106
|
+
### Expensive computations without memoization
|
|
107
|
+
A component does heavy work (filtering, sorting, formatting) on every render. Shows up as high avg render time. Fix with `useMemo`.
|
|
108
|
+
|
|
109
|
+
### State updates in effects causing render loops
|
|
110
|
+
An effect updates state on every render, causing unnecessary commit cycles. Look for unusually high commit counts in `profile timeline`.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Setup Guide
|
|
2
|
+
|
|
3
|
+
agent-react-devtools works with any React or React Native app. The `init` command auto-detects your framework and configures everything.
|
|
4
|
+
|
|
5
|
+
## Auto Setup (Recommended)
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd your-react-app
|
|
9
|
+
npx agent-react-devtools init
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This detects the framework and applies the minimal configuration needed.
|
|
13
|
+
|
|
14
|
+
Use `--dry-run` to preview changes without modifying files:
|
|
15
|
+
```bash
|
|
16
|
+
npx agent-react-devtools init --dry-run
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Framework-Specific Details
|
|
20
|
+
|
|
21
|
+
### Vite
|
|
22
|
+
|
|
23
|
+
`init` adds the Vite plugin to your config:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
// vite.config.ts
|
|
27
|
+
import { reactDevtools } from "agent-react-devtools/vite";
|
|
28
|
+
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
plugins: [reactDevtools(), react()],
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The plugin only runs in dev mode (`vite dev`). It injects the connect script before your app code loads. Zero app code changes needed.
|
|
35
|
+
|
|
36
|
+
### Next.js (App Router)
|
|
37
|
+
|
|
38
|
+
`init` creates a client component that imports the connect script and adds it to your root layout:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
// app/devtools.tsx
|
|
42
|
+
'use client';
|
|
43
|
+
import 'agent-react-devtools/connect';
|
|
44
|
+
export default function DevTools() { return null; }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then imports it in `app/layout.tsx`.
|
|
48
|
+
|
|
49
|
+
### Create React App
|
|
50
|
+
|
|
51
|
+
`init` prepends the import to `src/index.tsx`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import 'agent-react-devtools/connect';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### React Native / Expo
|
|
58
|
+
|
|
59
|
+
React Native apps auto-connect to the devtools WebSocket on port 8097 — no code changes needed.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
agent-react-devtools start
|
|
63
|
+
npx react-native start
|
|
64
|
+
# or: npx expo start
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For physical devices, reverse the port:
|
|
68
|
+
```bash
|
|
69
|
+
adb reverse tcp:8097 tcp:8097
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Manual Setup
|
|
73
|
+
|
|
74
|
+
If `init` doesn't cover your setup, add this as the first import in your entry point:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import 'agent-react-devtools/connect';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The connect script is:
|
|
81
|
+
- **SSR-safe** — no-ops on the server
|
|
82
|
+
- **Production-safe** — tree-shaken in production builds
|
|
83
|
+
- Connects via WebSocket with a 2-second timeout
|
|
84
|
+
|
|
85
|
+
## Verifying the Connection
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
agent-react-devtools status
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Expected output when connected:
|
|
92
|
+
```
|
|
93
|
+
Daemon: running (port 8097)
|
|
94
|
+
Apps: 1 connected, 42 components
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If `Apps: 0 connected`:
|
|
98
|
+
1. Check the app is running in dev mode
|
|
99
|
+
2. Check the console for WebSocket connection errors
|
|
100
|
+
3. Ensure no other DevTools instance is using port 8097
|