Set Up Your Salesforce DX Environment


The Salesforce Developer Experience (DX) is a set of tools that streamlines the entire development life cycle. It improves team development and collaboration, facilitates automated testing and continuous integration, and makes the release cycle more efficient and agile.

This Salesforce DX quick start begins with source code living in your version control system (VCS). It doesn’t matter which VCS you use, only that you use one. In this quick start, we assume you’re using Git and GitHub, as this is where we’ve stored the sample application, called the DreamHouse app.

What Is a Scratch Org?

Much of the setup you do for Salesforce DX enables you to use a new type of org called a scratch org. A scratch org is a dedicated, configurable, and short-term Salesforce environment that you can quickly spin up when starting a new project, a new feature branch, or a feature test.

What Is a Developer Hub Org?

A Developer Hub (Dev Hub) is the main Salesforce org that you and your team use to create and manage your scratch orgs. 

Enable Dev Hub in Your Trailhead Playground

While you can enable Dev Hub in any paid org, it’s always best to practice somewhere other than production. Instead, go ahead and enable Dev Hub in a Developer Edition org or Trailhead Playground to use with this project.

Get Your Trailhead Username and Password

You need your Dev Hub login credentials for this project. If you don't already know the username and password for the Developer Edition or Trailhead Playground org where you enabled Dev Hub, follow the steps in this article.

Install the Command Line Interface (CLI)

Use the Salesforce CLI to control the full application life cycle of your Salesforce apps. With it you can easily create environments for development and testing, synchronize source code between your orgs and VCS, and execute tests. 

  1. Install the CLI using the links below.
    Operating System
    Link to Installer
    Windows 32-bit
    Windows 64-bit
    Debian/Ubuntu 64
    Download the archive from one of the URLs in the manifest, extract the archive, then run the ./install script.
    Debian/Ubuntu x86
    Download the archive from one of the URLs in the manifest, extract the archive, then run the ./install script.
  2. Let’s make sure the CLI is properly installed and you know how to access online help for the commands. In a command window, enter sfdx.

    The sfdx command returns help topics and specific options such as sfdx force, sfdx plugins, and sfdx update. 
    Usage: sfdx COMMAND [command-specific-options]
     Help topics, type "sfdx help TOPIC" for more details:
     sfdx force # tools for the salesforce developer
     sfdx plugins # manage plugins
     sfdx update # update sfdx-cli

Log In to the Dev Hub

Let’s log in to your Dev Hub enabled org. 

  1. Create an alias DevHub by using -a and make this the default org using -d. To authorize the Dev Hub, in the command window enter the web login flow. The following command opens the Salesforce login page in the web browser:
    sfdx auth:web:login -d -a DevHub
  2. Log in using your Dev Hub org credentials. Please note that this is a special org for Salesforce DX. You must use a Dev Hub enabled org for this project.
  3. Click Allow.
    Authorization page for Salesforce CLI connected app
  4. After you authenticate in the browser, the CLI remembers your Dev Hub credentials. You see something like this in the Terminal:
    Successfully authorized with org id 00D1I000000n3H5UAI
    You may now close the browser

Now you can close the Dev Hub org web page and continue to work. Typically, you start your development work by creating a scratch org that’s part of this Dev Hub and use the scratch org for your Salesforce DX projects—we do this in a subsequent step. 

But up next, we set up a project on our local machine to test out the next step in developing with Salesforce DX.

Click Verify Step to confirm your hands-on org has authorized Salesforce CLI.

Keep learning for
Sign up for an account to continue.
What’s in it for you?
  • 1 in 4 land a new job
  • 50% receive a promotion or raise
  • 80% learn new technologies that boost their resume
  • 66% say it increases productivity
Source: Trailblazer Community Impact Survey 2019