Lightning Web Component

How To Create A Lightning Web Component | The Salesforce Developer Guide

For this, you first need to have Visual Studio Code in your system. If you don’t have that then first install it. 

After that, you need to open Visual Studio Code and open the command prompt using (Ctrl+Shift+p) or (command+shift+p) for windows and Mac OS respectively.

Step 1: Create a Project, In the command prompt enter >sfdx, it will show the options to create, select >SFDX:Create Project

Step 2: Select Standard Project Template

Step 3: After that enter your project name

dont miss out iconDon't forget to check out: Call Lightning Web Component From a Quick Action in Salesforce

Step 4: Now, you have created your project, but you need to Authorize the org, which means, whatever task you are performing, you need to reflect that on your Salesforce org, for this you need to connect visual studio code to your Salesforce org

Step 5: After you have Authorized your org, you need to go to once again open command prompt and enter create lightning web component, select this and your LWC is created.

Step 6 In your LWC component .html file

Enter the following code:

   <lightning-card title="First LWC" >
       <p>This is my, {EnterPhrase}!</p>
       <lightning-input label="Name" value={greeting} onchange={changeHandler}></lightning-input>

In your .js File enter the following code:

import { LightningElement } from 'lwc';
export default class First_LWC extends LightningElement {
    EnterPhrase = 'First LWC';
    changeHandler(event) {
        this.greeting =;

And at last, in .xml file

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="" >
   <isExposed>true</isExposed> <!-- true, so that LWC can be visible-->

dont miss out iconCheck out another amazing blog by Krati here: Displaying Field According to Its Datatype In Salesforce Lightning Component

After this, once again send the changes to your org, but this time you need to deploy this component to the Salesforce org.

Step 7: Now, to test how your LWC works, if you do not wish to add this on your org UI and simply want to test it, then go to your developer Console and create a Lightning Application.

Enter the following and click on preview.

<aura:application extends="force:slds">

Here is the result! 

In the name section, you can change the text, and accordingly, it will show you the output text.


  1. This blog provides a step-by-step guide on how to create a Lightning Web Component in Salesforce. It explains the basics of Lightning Web Components, such as component bundles, templates, and controllers. The article also provides an example of how to create a simple Lightning Web Component that displays a list of records. It's a useful resource for developers who are new to Lightning Web Components and want to learn how to create them. Additionally, as Imperium Dynamics is a Microsoft business applications partner, this guide can help bridge the gap between Salesforce and Microsoft Dynamics 365 through the use of Lightning Web Components.

Popular Salesforce Blogs