Set Up Your Salesforce DX Environment

Introduction

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.

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
    macOS
    https://sfdc.co/sfdx_cli_osx
    Windows 32-bit
    https://sfdc.co/sfdx_cli_win
    Windows 64-bit
    https://sfdc.co/sfdx_cli_win64
    Debian/Ubuntu 64
    https://sfdc.co/sfdx_cli_linux
    Download the archive from one of the URLs in the manifest, extract the archive, then run the ./install script.
    Debian/Ubuntu x86
    https://sfdc.co/sfdx_cli_linux_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.

    You see something like this:
    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 force: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.
    Image shows Salesforce authentication page for the Dev Hub Org

  4. After you authenticate in the browser, the CLI remembers your Dev Hub credentials. You see something like this in the Terminal:
    Successfully authorized rraodv@salesforcedx1.com 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.

We won't check any of your setup. Click Verify Step to go to the next step in the project.

retargeting