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
Copy file name to clipboardExpand all lines: README.md
+13-29Lines changed: 13 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,11 @@ sf plugins
129
129
130
130
Start a local development proxy server for webapp development with Salesforce authentication.
131
131
132
+
**Two operating modes:**
133
+
134
+
-**Command mode** (default): When `dev.command` is set in `webapplication.json` (or default `npm run dev`), the CLI starts the dev server. URL defaults to `http://localhost:5173`; override with `dev.url` or `--url` if needed.
135
+
-**URL-only mode**: When only `dev.url` or `--url` is provided (no command), the CLI assumes the dev server is already running and does not start it. Proxy only.
136
+
132
137
```bash
133
138
USAGE
134
139
$ sf webapp dev --name <webapp-name> --target-org <org-alias> [options]
@@ -138,50 +143,29 @@ REQUIRED FLAGS
138
143
-o, --target-org=<value> Salesforce org to authenticate against
139
144
140
145
OPTIONAL FLAGS
141
-
-u, --url=<value> Dev server URL (overrides webapplication.json)
146
+
-u, --url=<value> Dev server URL. Command mode: override default 5173. URL-only: required (server must be running)
142
147
-p, --port=<value> Proxy server port (default: 4545)
143
148
--open Open browser automatically
144
149
145
-
GLOBAL FLAGS
146
-
--flags-dir=<value> Import flag values from a directory
147
-
--json Format output as json
148
-
149
150
DESCRIPTION
150
-
Start a local development proxy server for webapp development.
151
-
152
-
This command starts a local HTTP proxy server that handles Salesforce
153
-
authentication and routes requests between your local dev server and
154
-
Salesforce APIs. It automatically spawns and monitors your dev server,
155
-
detects the URL, and provides health monitoring.
151
+
Starts a local HTTP proxy that injects Salesforce authentication and routes
152
+
requests between your dev server and Salesforce APIs. In command mode,
153
+
spawns and monitors the dev server (default URL: localhost:5173). In
154
+
URL-only mode, connects to an already-running dev server.
156
155
157
156
EXAMPLES
158
-
Start proxy with automatic dev server management:
157
+
Command mode (CLI starts dev server, default port 5173):
159
158
160
159
$ sf webapp dev --name myapp --target-org myorg --open
161
160
162
-
Use existing dev server:
161
+
URL-only mode (dev server already running):
163
162
164
163
$ sf webapp dev --name myapp --target-org myorg --url http://localhost:5173 --open
165
164
166
-
Use custom proxy port:
165
+
Custom proxy port:
167
166
168
167
$ sf webapp dev --name myapp --target-org myorg --port 8080 --open
169
168
170
-
SUPPORTED DEV SERVERS
171
-
- Vite
172
-
- Create React App (Webpack)
173
-
- Next.js
174
-
- Any server that outputs http://localhost:PORT
175
-
176
-
FEATURES
177
-
- Automatic Salesforce authentication injection
178
-
- Intelligent request routing (Salesforce vs dev server)
179
-
- WebSocket support for Hot Module Replacement (HMR)
The `webapplication.json` file is **optional**. All fields are also optional - missing fields use defaults.
239
+
The command operates in two distinct modes based on configuration:
240
240
241
-
#### Dev Configuration
241
+
| Mode | Configuration | Behavior |
242
+
|------|---------------|----------|
243
+
|**Command mode**|`dev.command` is set (or default `npm run dev`) | CLI starts the dev server. URL defaults to `http://localhost:5173`. Override with `dev.url` or `--url` if your dev server uses a different port. |
244
+
|**URL-only mode**|`dev.url` or `--url` only (no `dev.command`) | CLI assumes the dev server is already running. Does **not** start the dev server. Starts proxy only and forwards to the given URL. |
|`dev.command`| string | Command to start the dev server (e.g., `npm run dev`). When set, the CLI starts the dev server and uses default URL `http://localhost:5173` unless overridden. |`npm run dev`|
257
+
|`dev.url`| string | Dev server URL. **Command mode**: Override the default 5173 port if needed. **URL-only mode**: Required—the CLI assumes the server is already running and does not start it. |`http://localhost:5173`|
257
258
258
-
**Option B: Minimal manifest**
259
+
**Command mode (CLI starts dev server):**
259
260
260
261
```json
261
262
{
262
263
"dev": {
263
-
"command": "npm start"
264
+
"command": "npm run dev"
264
265
}
265
266
}
266
267
```
267
268
268
-
**Option C: Explicit URL (dev server already running)**
269
+
- CLI runs `npm run dev` and waits for the server to be ready
270
+
- Default URL: `http://localhost:5173`
271
+
- Override port: add `"url": "http://localhost:3000"` if your dev server uses a different port
272
+
273
+
**URL-only mode (proxy only, server already running):**
269
274
270
275
```json
271
276
{
@@ -275,7 +280,15 @@ If no `webapplication.json` exists:
275
280
}
276
281
```
277
282
278
-
Use this when you want to start the dev server yourself.
283
+
- No `dev.command` — CLI does **not** start the dev server
284
+
- You must start the dev server yourself (e.g., `npm run dev` in another terminal)
285
+
- CLI starts only the proxy and forwards to the given URL
286
+
287
+
**No manifest (uses defaults):**
288
+
289
+
- Dev command: `npm run dev`
290
+
- Default URL: `http://localhost:5173`
291
+
- Manifest watching: disabled
279
292
280
293
#### Routing Configuration (Optional)
281
294
@@ -375,19 +388,19 @@ Automatically detects Salesforce Code Builder environment and binds to `0.0.0.0`
375
388
376
389
## The `--url` Flag
377
390
378
-
The `--url` flag provides control over which dev server URL the proxy uses. It has smart behavior depending on whether the URL is already available.
391
+
The `--url` flag overrides the dev server URL. Behavior depends on whether you have a command configured:
379
392
380
-
### Behavior
393
+
| Scenario | Command in manifest? |`--url` behavior |
0 commit comments