You need CLI for VsCode, so let’s install the CLI before we install visual studio code-
Install the Command Line Interface (CLI)
- Install the CLI from https://developer.salesforce.com/tools/sfdxcli.
- Confirm the CLI is properly installed and on the latest version by running the following command from the command line-
sfdx update
Install Visual Studio Code (VsCode)
- 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
. - Search for
Salesforce Extension Packand click Install.

We have installed cli and vscode. Now we need to create project first in vscode before creating a lwc component. So, lets create a project first and authorize it with an org, then we will create a lwc component.
Create a Salesforce Project in VsCode
- Press Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS)
- Type sfdx and then select SFDX: Create Project or SFDX: Create Project with Manifest and enter.
- Then select a folder and click Create Project.
Note: SFDX: Create Project will create project without package.xml file while SFDX: Create Project with Manifest will create a project with package.xml.
Authorize your Org
- Press Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS)
- Type Authorize and then select ‘SFDX: Authorize an Org’.
- You will be presented with below options-
- Project Default – Select this option if your url is defined in package.json
- Sandbox – Select this option if you are developing your component in sandbox
- Production – Select this option if you want to create project for dev or production environment.
- Custom – Select this option if you are not sure about sandbox or production. You will need to enter url in next step if you select this option.
- Choose accordingly and then you will be directed to browser where you will enter credentials and login.
- Now you can close your browser once you are successfully authorized. You will see ‘Successfully authorized’ message in output panel as shown below upon successful authorization.

Now lets create a lwc component.