Wednesday, October 9, 2019

Introducing Local Development Server for Salesforce Lightning Web Components

This post explains local development in salesforce lightning web components(lwc)

Note: Currently, This feature is in beta stage

As a salesforce developer, we used to develop code in developer org/sandbox, to develop newly introduced lightning web components we are using vs code or other code editors which are support for lwc development.
Salesforce recommends the vs code editor. As we develop code in VS Code we need to push the code each and every time it's changed back to our Salesforce Org to test the changes. sometimes it will take a lot of time to push the code to salesforce.

Now salesforce introduced the local development option to build, run and test our component from Local server itself instead of deploying into Salesforce Org, salesforce made it easy for us to build the component and fix the errors in local itself before pushing to salesforce org and also we have the option to access Salesforce real-time data using LDS, UI API, and Apex.

The Local Development Server is a Salesforce CLI plugin that configures and runs a Lightning Web Components-enabled server on your computer. Now you can develop Lightning Web Component modules and see live changes without publishing your components to an org.

Prerequisites:
   1.  Install VS Code Editor 
   2.  Install Salesforce Extension Pack into Visual Studio Code
   3.  Install Salesforce CLI

Once install the prerequisites, configure the SFDX project in VS Code.
  1.  SFDX: Create Project
  2.  SFDX: Create Project with Manifest
  3.  SFDX: Authorize an Org

Follow the below steps to configure the Lightning Web Components with local development server (LWC dev server)
Step:1
Open a new terminal window and run the following command to install the local development server.
 sfdx plugins:install @salesforce/lwc-dev-server

Step:2
Check for updates to the local development server.
 sfdx plugins:update
Step:3
Once the plugin is installed you can run the Local Development Server on your Salesforce project by running the start command. Note that you will want to be authorized into an org before you start the server so you can take advantage of the data proxy features.
sfdx force:lightning:lwc:start

Now the local server is started, you can view the server at http://localhost:3333/

1 comment:

  1. How to get the data from sandbox to local environment?

    ReplyDelete