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 6 years and this is for me a revolution!!!
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
- 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.
- Productivity: You can set up multiple development environments, share with the team members and have a consistency in your development environments.
- 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 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.
If you like this post then please share your feedback in comment box. Want to become our guest blogger then email us : email@example.com