@vercel/next-browser 0.1.8 → 0.3.0

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/README.md CHANGED
@@ -1,83 +1,184 @@
1
1
  # @vercel/next-browser
2
2
 
3
- Programmatic access to React DevTools and the Next.js dev server. Everything
4
- you'd click through in a GUI — component trees, props, hooks, PPR shells,
5
- build errors, Suspense boundaries exposed as shell commands that return
6
- structured text.
3
+ React DevTools and the Next.js dev overlay as shell commands — component
4
+ trees, props, hooks, PPR shells, errors, network, accessibility snapshots —
5
+ structured text that agents can parse and act on.
7
6
 
8
- Built for agents. An LLM can't read a DevTools panel, but it can run
9
- `next-browser tree`, parse the output, and decide what to inspect next. Each
7
+ An LLM can't click through a DevTools panel, but it can run
8
+ `next-browser snapshot`, read the output, `click e3`, and keep going. Each
10
9
  command is a stateless one-shot against a long-lived browser daemon, so an
11
10
  agent loop can fire them off without managing browser lifecycle.
12
11
 
13
12
  ## Getting started
14
13
 
15
- You don't install or run this directly. Your agent does.
14
+ **As a skill** (recommended) from your Next.js repo:
16
15
 
17
- 1. **Add the skill to your project.** From your Next.js repo:
16
+ ```bash
17
+ npx skills add vercel-labs/next-browser
18
+ ```
18
19
 
19
- ```bash
20
- npx skills add vercel-labs/next-browser
21
- ```
20
+ Works with Claude Code, Cursor, Cline, and [others](https://skills.sh).
21
+ Start your agent in the project and type `/next-browser` to invoke the
22
+ skill. It installs the CLI and Chromium if needed, asks for your dev server
23
+ URL, and from there it's pair programming — tell it what you're debugging
24
+ and it drives the browser for you.
22
25
 
23
- Works with Claude Code, Cursor, Cline, and [others](https://skills.sh).
26
+ **Manual install:**
24
27
 
25
- 2. **Start your agent** in that project.
28
+ ```bash
29
+ pnpm add -g @vercel/next-browser # or npm, yarn
30
+ playwright install chromium
31
+ ```
26
32
 
27
- 3. **Type `/next-browser`** to invoke the skill.
33
+ Requires Node >= 20.
28
34
 
29
- 4. The skill checks for the CLI and **installs `@vercel/next-browser`
30
- globally** if it's missing (plus `playwright install chromium`).
35
+ ## Commands
31
36
 
32
- 5. It asks for your dev server URL and any cookies it needs, opens the
33
- browser, and from there it's **pair programming** — tell it what you're
34
- debugging and it drives the tree, navigates pages, inspects components,
35
- and reads errors for you.
37
+ ### Browser lifecycle
36
38
 
37
- That's the whole flow. Run `npx skills upgrade` later to pull updates.
39
+ | Command | Description |
40
+ | ------------------------------------ | -------------------------------------------------- |
41
+ | `open <url> [--cookies-json <file>]` | Launch browser and navigate (with optional cookies) |
42
+ | `close` | Close browser and kill daemon |
38
43
 
39
- The rest of this README documents the raw CLI for the rare case where you're
40
- scripting it yourself.
44
+ ### Navigation
41
45
 
42
- ---
46
+ | Command | Description |
47
+ | ------------------ | --------------------------------------------------------- |
48
+ | `goto <url>` | Full-page navigation (new document load) |
49
+ | `ssr lock` | Block external scripts on all navigations (SSR-only mode) |
50
+ | `ssr unlock` | Re-enable external scripts |
51
+ | `push [path]` | Client-side navigation (interactive picker if no path) |
52
+ | `back` | Go back in history |
53
+ | `reload` | Reload current page |
54
+ | `restart-server` | Restart the Next.js dev server (clears caches) |
43
55
 
44
- ## Manual install
56
+ ### Inspection
57
+
58
+ | Command | Description |
59
+ | ----------------- | ------------------------------------------------------------- |
60
+ | `tree` | Full React component tree (hierarchy, IDs, keys) |
61
+ | `tree <id>` | Inspect one component (props, hooks, state, source location) |
62
+ | `snapshot` | Accessibility tree with `[ref=eN]` markers on interactive elements |
63
+ | `errors` | Build and runtime errors for the current page |
64
+ | `logs` | Recent dev server log output |
65
+ | `network [idx]` | List network requests, or inspect one (headers, body) |
66
+ | `preview [caption]` | Screenshot + open in viewer window (accumulates across calls) |
67
+ | `screenshot` | Viewport PNG to a temp file (`--full-page` for entire page) |
68
+
69
+ ### Interaction
70
+
71
+ | Command | Description |
72
+ | ---------------------------- | ---------------------------------------------------------- |
73
+ | `click <ref\|text\|selector>` | Click via real pointer events (works with Radix, Headless UI) |
74
+ | `fill <ref\|selector> <value>` | Fill a text input or textarea |
75
+ | `eval [ref] <script>` | Run JS in page context (supports `--file` and stdin) |
76
+ | `viewport [WxH]` | Show or set viewport size |
77
+
78
+ ### Performance & PPR
79
+
80
+ | Command | Description |
81
+ | -------------- | ------------------------------------------------------------ |
82
+ | `perf [url]` | Core Web Vitals + React hydration timing in one pass |
83
+ | `ppr lock` | Freeze dynamic content to inspect the static shell |
84
+ | `ppr unlock` | Resume dynamic content and print shell analysis |
85
+
86
+ ### Next.js MCP
87
+
88
+ | Command | Description |
89
+ | -------------- | ----------------------------------------------- |
90
+ | `page` | Route segments for the current URL |
91
+ | `project` | Project root and dev server URL |
92
+ | `routes` | All app router routes |
93
+ | `action <id>` | Inspect a server action by ID |
94
+
95
+ ## Examples
96
+
97
+ **Inspect what's on the page and interact with it:**
45
98
 
46
- ```bash
47
- pnpm add -g @vercel/next-browser
99
+ ```
100
+ $ next-browser open http://localhost:3000
101
+ $ next-browser snapshot
102
+ - navigation "Main"
103
+ - link "Home" [ref=e0]
104
+ - link "Dashboard" [ref=e1]
105
+ - main
106
+ - heading "Settings"
107
+ - tablist
108
+ - tab "General" [ref=e2] (selected)
109
+ - tab "Security" [ref=e3]
110
+
111
+ $ next-browser click e3
112
+ clicked
113
+
114
+ $ next-browser snapshot
115
+ - tablist
116
+ - tab "General" [ref=e0]
117
+ - tab "Security" [ref=e1] (selected)
48
118
  ```
49
119
 
50
- Requires Node `>=20`.
120
+ **Profile page load performance:**
51
121
 
52
- ## Commands
122
+ ```
123
+ $ next-browser perf http://localhost:3000/dashboard
124
+ # Page Load Profile — http://localhost:3000/dashboard
125
+
126
+ ## Core Web Vitals
127
+ TTFB 42ms
128
+ LCP 1205.3ms (img: /_next/image?url=...)
129
+ CLS 0.03
130
+
131
+ ## React Hydration — 65.5ms (466.2ms → 531.7ms)
132
+ Hydrated 65.5ms (466.2 → 531.7)
133
+ Commit 2.0ms (531.7 → 533.7)
134
+ ...
135
+ ```
136
+
137
+ **Debug the PPR shell:**
53
138
 
54
139
  ```
55
- open <url> [--cookies-json <file>] launch browser and navigate
56
- close close browser and daemon
57
-
58
- goto <url> full-page navigation (new document load)
59
- ssr-goto <url> goto but block external scripts (SSR shell)
60
- push [path] client-side navigation (interactive picker if no path)
61
- back go back in history
62
- reload reload current page
63
- capture-goto [url] capture loading sequence (PPR shell → hydration → data)
64
- restart-server restart the Next.js dev server (clears fs cache)
65
-
66
- ppr lock enter PPR instant-navigation mode (requires cacheComponents)
67
- ppr unlock exit PPR mode and show shell analysis
68
-
69
- tree show React component tree
70
- tree <id> inspect component (props, hooks, state, source)
71
-
72
- viewport [WxH] show or set viewport size (e.g. 1280x720)
73
- screenshot save full-page screenshot to tmp file
74
- eval <script> evaluate JS in page context
75
-
76
- errors show build/runtime errors
77
- logs show recent dev server log output
78
- network [idx] list network requests, or inspect one
140
+ $ next-browser ppr lock
141
+ locked
142
+ $ next-browser goto http://localhost:3000/dashboard
143
+ $ next-browser preview "PPR shell — locked"
144
+ preview /var/folders/.../next-browser-screenshot.png
145
+ $ next-browser ppr unlock
146
+ # PPR Shell Analysis — 131 boundaries: 3 dynamic holes, 128 static
147
+
148
+ ## Quick Reference
149
+ | Boundary | Type | Primary blocker | Source |
150
+ | --- | --- | --- | --- |
151
+ | TrackedSuspense | component | usePathname (client-hook) | tracked-suspense.js |
79
152
  ```
80
153
 
154
+ **Inspect a React component:**
155
+
156
+ ```
157
+ $ next-browser tree
158
+ 0 38167 - Root
159
+ 1 38168 38167 HeadManagerContext.Provider
160
+ 2 38169 38168 Root
161
+ ...
162
+ 224 46375 46374 DeploymentsProvider
163
+
164
+ $ next-browser tree 46375
165
+ path: Root > ... > DeploymentsProvider
166
+ DeploymentsProvider #46375
167
+ props:
168
+ children: [<Lazy />, <Lazy />, <span />, <Lazy />, <Lazy />]
169
+ hooks:
170
+ IsMobile: undefined (1 sub)
171
+ Router: undefined (2 sub)
172
+ source: app/.../deployments/_parts/context.tsx:180:10
173
+ ```
174
+
175
+ ## How it works
176
+
177
+ A daemon process launches Chromium with the React DevTools extension
178
+ pre-loaded and listens on a Unix domain socket (named pipe on Windows).
179
+ CLI commands send JSON-RPC messages to the daemon and print the response.
180
+ The browser stays open across commands — no per-command startup cost.
181
+
81
182
  ## License
82
183
 
83
184
  MIT