SFDX With Visual Studio Codespace

Recently I have seen that there is an online version of Visual Studio (VS) Code, which is called Visual Studio Codespace. I have set up a sfdx development environment in a couple of hours, and the result is AMAZING! Basically, you can develop wherever you have a browser. I have been developing Salesforce for more than six years and this is, for me, a revolution!!!

YouTube video

What is Visual Studio Codespace

Cloud hosted development environment which runs on a Linux virtual machine and powered with Visual Studio Code UI which can live in the browser. So it is a kind of browser based editor and plus cloud hosted development environment.

Since Visual Studio Codespace has an embedded terminal in it, you can run all the terminal commands there. You can upload a program (e.g. npm), set your environment variable, run commands (e.g. sfdx), run scripts, make external calls etc.. So your online development environment fully equipped with the power of a Linux terminal functionalities. Surprisingly all the Visual Studio Code functionalities I have mainly used are replicated in Codesapce. So far I could not see any missing feature

Benefits of VS Codesapce for Salesforce Developer

  1. Mobility: You do not have any dependency on your OS system. What you need is only a reliable web browser. So in work you can use your Mac but at home you can use Windows for development. Mine favourite is Linux Mint. 
  2. Productivity: You can set up multiple development environments, share with the team members and have a consistency in your development environments.
  3. SFDX: Since it is a Linux virtual machine you can set sfdx environments and repositories, and you can continue your development 100% online.

Set Up VS Codespace for Salesforce Development

  • Get an instance of VS Codespace: For this you need to have a Microsoft account. If you do not have an account  then you create one right away and then create a codespace instance. Follow the link and then “Get Started” (it is free for 12 months). 

 When you are logged in to VS Codespace, you will see the “Create Codespace” button, click on it and after basic configuration the online VS Code is there. Here you go!

  • Setup SFDX: Once you are in the online VS Code then you can open the terminal with Ctrl+Shift+C or from the menu. 

Some programs are pre-installed such as Nodejs, npm, git etc. So you can install sfdx with the command npm install sfdx-cli — global. 

  • SFDX Connect DevHub: Normally in our local development environment we can easily authorize our Dev Hub with sfdx force:auth:web:login -a YourOrgAliasName but this does not work in online VS Codespace. You need to authorize with JWT-Based Flow. In this link there is a procedure on how to set it up.

That is it, now you can pull your repository here and continue your development totally online

PS: Recently Salesforce announced that there will be a Salesforce Code builder which is principally the same with this solution. Since there are a couple of months to release it, this solution is worth starting to start.

Further Learning

Aykut Parlak
Aykut Parlak

Lead Salesforce Developer

Articles: 3

4 Comments

  1. I logged into codespaces url with my free hotmail account. When i try to create a codespace, it asks me to create a free azure account. As of now this account is free for 12 months but after that there should be a payment plan? Is this right?

  2. I think its not free for 12 months . for Free subscription of azure 200$ or 13330 INR will be credited for first 30 days only… not after that ..Usage of code space will be reduced from that free credits ..So after One month we can not use code space if we do not upgrade azure

  3. Hi,
    do you have some tutorial video with showing how install it and debug in normal Visual Studio 2019, because this ‘Code’ version is crazy and we don’t know how debug webpage production and test version -.- 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *