View the full documentation in the Lightning Web Components Developer Guide.
The Local Development Server is a Salesforce CLI plug-in that configures and runs a Lightning Web Components-enabled server on your computer. You can develop Lightning web components and see live changes without publishing the components to an org.
Run Local Development SFDX Commands in VS Code
The local development server uses the following SFDX commands.
View the local development server’s SFDX commands from VS Code’s command palette by pressing
p. By typing in “local development,” all three commands are visible.
SFDX: Open Local Development Server
If the local development server isn’t currently running, this command starts the server and opens localhost:333 in your web browser. If the server is already running, then the command only opens localhost:3333 in your browser.
SFDX: Start Local Development Server
This command starts the local development server. If you already started the server from VS Code, then VS Code gives the option to open it in the browser or restart it. If you already started the server from the command line, then VS code shows an error in the output console.
SFDX: Stop Local Development Server
This command stops the local development server.
Preview Lightning Web Components in VS Code
c-hello from the HTML code.
c-hello from the HTML file.
After you select SFDX: Preview Component Locally, the Command Palette displays a list of preview options. You can choose to preview your component in the desktop browser or in a virtual mobile device (iOS or Android). Mobile previews require additional setup. See “Set Up Your Dev Environment” in the Lightning Web Components Dev Guide.
Here’s the previewed component on the local development server’s desktop browser.
Here’s the previewed component on a virtual mobile device.