You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`host`|`"localhost"`| Socket connection to frontend should use this host. |
56
56
|`isAppActive`|| (Optional) function that returns true/false, telling DevTools when it's ready to connect to React. |
57
+
|`path`|`""`| Path appended to the WebSocket URI (e.g. `"/__react_devtools__/"`). Useful when proxying through a reverse proxy on a subpath. A leading `/` is added automatically if missing. |
57
58
|`port`|`8097`| Socket connection to frontend should use this port. |
58
59
|`resolveRNStyle`|| (Optional) function that accepts a key (number) and returns a style (object); used by React Native. |
59
60
|`retryConnectionDelay`|`200`| Delay (ms) to wait between retrying a failed Websocket connection |
Start a socket server (used to communicate between backend and frontend) and renders the DevTools UI.
146
147
147
148
This method accepts the following parameters:
148
149
| Name | Default | Description |
149
150
|---|---|---|
150
-
|`port`|`8097`|Socket connection to backend should use this port. |
151
-
|`host`|`"localhost"`|Socket connection to backend should use this host. |
151
+
|`port`|`8097`|Port the local server listens on. |
152
+
|`host`|`"localhost"`|Host the local server binds to. |
152
153
|`httpsOptions`||_Optional_ object defining `key` and `cert` strings. |
153
154
|`loggerOptions`||_Optional_ object defining a `surface` string (to be included with DevTools logging events). |
155
+
|`path`||_Optional_ path to append to the WebSocket URI served to connecting clients (e.g. `"/__react_devtools__/"`). Also set via the `REACT_DEVTOOLS_PATH` env var in the Electron app. |
156
+
|`clientOptions`||_Optional_ object with client-facing overrides (see below). |
157
+
158
+
##### `clientOptions`
159
+
160
+
When connecting through a reverse proxy, the client may need to connect to a different host, port, or protocol than the local server. Use `clientOptions` to override what appears in the `connectToDevTools()` script served to clients. Any field not set falls back to the corresponding server value.
161
+
162
+
| Field | Default | Description |
163
+
|---|---|---|
164
+
|`host`| server `host`| Host the client connects to. |
165
+
|`port`| server `port`| Port the client connects to. |
166
+
|`useHttps`| server `useHttps`| Whether the client should use `wss://`. |
167
+
168
+
These can also be set via environment variables in the Electron app:
169
+
170
+
| Env Var | Description |
171
+
|---|---|
172
+
|`REACT_DEVTOOLS_CLIENT_HOST`| Overrides the host in the served client script. |
173
+
|`REACT_DEVTOOLS_CLIENT_PORT`| Overrides the port in the served client script. |
174
+
|`REACT_DEVTOOLS_CLIENT_USE_HTTPS`| Set to `"true"` to make the served client script use `wss://`. |
175
+
176
+
##### Reverse proxy example
177
+
178
+
Run DevTools locally on the default port, but tell clients to connect through a remote proxy:
179
+
```sh
180
+
REACT_DEVTOOLS_CLIENT_HOST=remote.example.com \
181
+
REACT_DEVTOOLS_CLIENT_PORT=443 \
182
+
REACT_DEVTOOLS_CLIENT_USE_HTTPS=true \
183
+
REACT_DEVTOOLS_PATH=/__react_devtools__/ \
184
+
react-devtools
185
+
```
186
+
The server listens on `localhost:8097`. The served script tells clients:
Copy file name to clipboardExpand all lines: packages/react-devtools/README.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,31 @@ This will ensure the developer tools are connected. **Don’t forget to remove i
87
87
88
88
## Advanced
89
89
90
-
By default DevTools listen to port `8097` on `localhost`. The port can be modified by setting the `REACT_DEVTOOLS_PORT` environment variable. If you need to further customize host, port, or other settings, see the `react-devtools-core` package instead.
90
+
By default DevTools listen to port `8097` on `localhost`. If you need to customize the server or client connection settings, the following environment variables are available:
91
+
92
+
| Env Var | Default | Description |
93
+
|---|---|---|
94
+
|`HOST`|`"localhost"`| Host the local server binds to. |
95
+
|`PORT`|`8097`| Port the local server listens on. |
96
+
|`REACT_DEVTOOLS_PORT`|| Alias for `PORT`. Takes precedence if both are set. |
97
+
|`KEY`|| Path to an SSL key file. Enables HTTPS when set alongside `CERT`. |
98
+
|`CERT`|| Path to an SSL certificate file. Enables HTTPS when set alongside `KEY`. |
99
+
|`REACT_DEVTOOLS_PATH`|| Path appended to the WebSocket URI served to clients (e.g. `/__react_devtools__/`). |
100
+
|`REACT_DEVTOOLS_CLIENT_HOST`|`HOST`| Overrides the host in the script served to connecting clients. |
101
+
|`REACT_DEVTOOLS_CLIENT_PORT`|`PORT`| Overrides the port in the script served to connecting clients. |
102
+
|`REACT_DEVTOOLS_CLIENT_USE_HTTPS`|| Set to `"true"` to make the served client script use `wss://`. |
103
+
104
+
When connecting through a reverse proxy, use the `REACT_DEVTOOLS_CLIENT_*` variables to tell clients to connect to a different host/port/protocol than the local server:
105
+
106
+
```sh
107
+
REACT_DEVTOOLS_CLIENT_HOST=remote.example.com \
108
+
REACT_DEVTOOLS_CLIENT_PORT=443 \
109
+
REACT_DEVTOOLS_CLIENT_USE_HTTPS=true \
110
+
REACT_DEVTOOLS_PATH=/__react_devtools__/ \
111
+
react-devtools
112
+
```
113
+
114
+
For more details, see the [`react-devtools-core` documentation](https://github.com/facebook/react/tree/main/packages/react-devtools-core).
0 commit comments