To create and develop Lightning Web Components and use their powerful features and performance benefits, you need to set up followings:
- Install Salesforce CLI.
- Install Visual Studio Code and extensions for Salesforce DX.
- Install the CLI from Salesforce CLI.
- Confirm the CLI is properly installed and on the latest version by running the following command from the command line. sfdx update You should see output like sfdx-cli: Updating CLI....
- Download and install the latest version of Visual Studio Code for your operating system. If you already have Visual Studio Code installed, there's no need to reinstall it.
- Launch Visual Studio Code.
- On the left toolbar, click the Extensions icon Visual Studio Code's Extension icon. Search for Salesforce Extension Pack and click to Install.
Now that you've installed Visual Studio Code and enabled the necessary extensions, you need to test them out.
- In Visual Studio Code, open the Command Palette by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
- Type SFDX.
- Select SFDX: Authorize an Org.
- Press Enter to accept the Project Default login URL option.
- Press Enter to accept the default alias. This opens the Salesforce login in a separate browser window.
- Log in using your dev organization credentials.
- If prompted to allow access, click Allow.
- Right-click the default folder under force-app/main.
- Click SFDX: Deploy Source to Org.
- In the Output tab of the integrated terminal, view the results of your deployment. If the command ran successfully, a Deployed Source message lists the three files that were uploaded to the org.
- In Visual Studio Code, open the Command Palette by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
- Type SFDX.
- Select SFDX: Open Default Org. This opens your organization in a separate browser.
- From the App Launcher(), find and select Sales.
- Click gear icon then select Edit Page.
- Drag the helloWorld Lightning web component from the Custom area of the Lightning Components list to the top of the Page Canvas. (You can drag drop component you want to add in page).
- Click Save.
- Click Activate.
- Click Assign as Org Default.
- Click Save.
- Click Save again, then click to return to the page.
- Refresh the page to view your new component.
Refresh the page to view your new component.
- Introducing Lightning Web Components - Salesforce Lightning Component Library
- Explore Trailhead and Sample Code - Salesforce Lightning Component Library
- Access Static Resources - Salesforce Lightning Component Library
- Components - Salesforce Lightning Component Library - Ready to use built in components