At present, there is a lot going in Salesforce, from the developers’ point of view and one such thing that I noticed, is that Salesforce is recommending to use VS Code and SFDX.

Salesforce also recently announced Lightning Web Components, so I decided to connect my existing Sandbox to the VS code and see how it works. In this blog, we will go through the basics of how we can get started with the VS code and SFDX. In my next blog, we will learn about LWC and how it is different from Aura components.

NOTE: All the orgs in Salesforce are upgraded to Spring '19 at the time I started this blog. Most of my work related to LWC was done in pre-release org.

So, just an FYI for you guys, I referred this link to come up with this blog and here I will be simplifying the steps for you.

Another thing to note is that, in my case, I am connecting my Sandbox to the VS code using SFDX. You may even consider connecting to a DEV org.

  • Next step is to create a folder in your system and using the VS Code, open the folder.
Select Open Folder
  • Run the following code to create the basic skeleton of the project. Make sure you replace the <project name> with the desired name.
sfdx force:project:create --projectname "<project name>" --manifest
NOTE: You can use the inbuilt terminal provided in VS code to run these commands.
  • Change the sfdcLoginUrl in the sfdx-project.json as we are connecting to the Sandbox. If you are using DEV org, you can skip this step.
  "packageDirectories": [
      "path": "force-app",
      "default": true
  "namespace": "",
  "sfdcLoginUrl": "",
  "sourceApiVersion": "45.0"
  • Connect to your Salesforce sandbox using below command. Remember to change the URL to if you are using a DEV org.
  • This command will open a browser window with a login screen where you have to provide a username and password for authentication.
sfdx force:auth:web:login -r
  • Retrieve the code from your existing org. There are different ways to do this, however, we will be using the package.xml file located under the manifest folder. Make sure you replace <salesforce-user-name> with an actual user name.
sfdx force:source:retrieve -u <salesforce-user-name> -x manifest/package.xml
  • The above step will retrieve the code in your local system and we can now make local changes.
  • Once your changes are done, use the following command to deploy your code to the Sandbox.
sfdx force:source:deploy -u <salesforce-user-name> -x manifest/package.xml
  • The above command uses the package.xml file for deployment, however, let’s say you have to deploy just a folder or a specific Apex class, you can use the following commands.
sfdx force:source:deploy -u <salesforce-user-name> -p force-app\main\default
sfdx force:source:deploy -u <salesforce-user-name> -m ApexClass:MyApexClass
  • You can read more about sfdx commands here.

Do let me know any feedbacks by posting a comment below.