Chapter 9: Lightning Web Component Local Development

Salesforce made it easy for us to build the component and fix the errors in local itself before pushing to salesforce org.

In this chapter we will learn local development to build, run and test our component from Local server itself instead of deploying into Salesforce Org, The Local Development Server is a Salesforce CLI plugin that configures and runs a Lightning Web Components-enabled server on your computer.

Prerequisites

  • Visual Studio Code
  • Salesforce Extension Pack
  • Salesforce CLI

To Do installation learn it from earlier Chapter – Install Developer Tools for LWC

Install the Local Development Server

The local development server is a Salesforce CLI plug-in.

Run this command from a command-line interface.

sfdx plugins:install @salesforce/lwc-dev-server

Check for updates to the local development server.

sfdx plugins:update

Check if Plugins are installed properly
sfdx plugins

Create or Clone a Salesforce DX Project

To create project – do SFDX: Create Project.

To Clone project – Go to git to clone your favorite project eg – lwc-recipes

Enable Dev Hub in an Org

Authorize a Developer Hub (Dev Hub) in the VS Code and through CMD.

sfdx force:auth:web:login -d -a LWC-Hub

Create a Scratch org

sfdx force:org:create -s -f config/project-scratch-def.json -a "locallwc"

Start the server

sfdx force:lightning:lwc:start

View the LWC Local Development server at http://localhost:3333/

You can see all the LWC that you created in your org. Click on your favorite component to run.

  • chello: you can see this web component rendered in-browser without deploying to the org.

  • If you click on the button “View in VS Code” this will quickly open the component code in your VS Code IDE.
  • When you can make any changes in the component code, those changes will refresh in the browser immediately.

Together we can learn faster 

Join LWC study group on Telegram 

Subscribe to Youtube channel and blog to get latest updates

 

Reference

Lightning Web Component Video Gallery 

Did you enjoy this article?
Signup today and receive free updates straight in your inbox.
I agree to have my personal information transfered to MailChimp ( more information )
50% LikesVS
50% Dislikes