Preview a Lightning Experience app locally and in real-time, without deploying it.
Description for lightning dev app
Use Local Dev to see local changes to your app in a real-time preview that you don't have to deploy or manually refresh. To let you quickly iterate on your Lightning web components (LWCs) and pages, your app preview automatically refreshes when Local Dev detects source code changes.
When you edit these local files with Local Dev enabled, your org automatically reflects these changes.
<ul><li>Basic HTML and CSS edits to LWCs</li><li>JavaScript changes to LWCs that don't affect the component's public API</li><li>Importing new custom LWCs</li><li>Importing another instance of an existing LWC</li></ul>To apply any other local changes not listed above, you must deploy them to your org using the sf project deploy start command.
When you make changes directly in your org (like saving new component properties), they're automatically deployed to your live app. To update your local version of the app with those changes, you must retrieve them from your org using the sf project retrieve start command.
If you run the command without flags, it displays a list of devices for you to choose from. Then it lists the apps that it found in your local DX project for you to choose. Use the --device or --name flags to bypass the questions. The command also asks if you want to enable Local Dev in your org if it isn't already.
To learn more about Local Dev enablement, considerations, and limitations, see the Lightning Web Components Developer Guide (https://developer.salesforce.com/docs/platform/lwc/guide/get-started-test-components.html).
Flags
| Flag Name (Long) | Flag Name (Short) | Description |
|---|---|---|
| <code>‑‑api‑version</code> | N/A | Type: Value<br><br>Override the api version used for api requests made by this command |
| <code>‑‑device‑id</code> | <code>‑i</code> | Type: Value<br><br>ID of the mobile device to display the preview if device type is set to ios or android. The default value is the ID of the first available mobile device. |
| <code>‑‑device‑type</code> | <code>‑t</code> | Type: Value<br>Valid Values: desktop, ios, android<br><br>Type of device to display the app preview. |
| <code>‑‑flags‑dir</code> | N/A | Type: Value<br><br>Import flag values from a directory. |
| <code>‑‑name</code> | <code>‑n</code> | Type: Value<br><br>Name of the Lightning Experience app to preview. |
| <code>‑‑target‑org</code> | <code>‑o</code> | Type: Value<br>Required<br><br>Username or alias of the target org. Not required if the target-org configuration variable is already set. |
Examples for lightning dev app
Preview the default app for the target org "myOrg" in a desktop environment:
sf lightning dev app --target-org myOrg
Preview the app "myApp" for the target org "myOrg" in a desktop environment:
sf lightning dev app --name MyApp --target-org myOrg --device-type desktop
Preview the default app for target org "myOrg" on an iOS device:
sf lightning dev app --target-org myOrg --device-type ios --device-id "iPhone 15 Pro Max"
<!-- prettier-ignore-end -->