Set Up Your Developer Hub

The Developer Hub (DevHub) lets you create and manage scratch orgs. The scratch org is a source-driven and disposable deployment of Salesforce code and metadata, made for developers and automation. This Getting Started Guide uses scratch orgs for developing a Salesforce Function, however you first need to configure your DevHub org for Functions.

Login and Set an Alias To Your DevHub

Log in to your DevHub using your username/password with the following command:

  • -a set an alias for the authenticated org which you'll use in subsequent CLI commands
  • -d set this org as the default DevHub for creating scratch orgs

Confirm DevHub Setup is Enabled

In your DevHub org, from Setup, enter "Dev Hub" in the Quick Find box. Select Dev Hub and make sure the "Enable Dev Hub" switch is toggled on.

This sets the DevHub org that CLI commands will use, but you’ll also need to authenticate your org with Salesforce Functions, which we’ll do in the next section.

Enable Functions in DevHub

Before your org can work with Salesforce Functions, you must enable the Salesforce Functions org setting. Doing this creates an authenticated connection for requests between your org and Salesforce Functions. Doing this also ensures that subsequent scratch orgs created from the Functions enabled DevHub org will automatically have this org setting enabled.

To authenticate Salesforce Functions in your DevHub org, go to Setup and in the Quick Find box search for "Functions". Select the Functions setup page.

Functions Setup screenshot

This setup page is only available in orgs that have Lightning Experience enabled, not Salesforce Classic.

Click Enable Functions in the Functions setup page to start creating the authenticated connection between your org and Salesforce Functions. A Salesforce sign-in browser window will open requesting your Salesforce Functions login information.

For beta, use the same credentials as your DevHub admin login credentials, or the Salesforce Functions account credentials provided to you by Salesforce.

After you’ve entered your Salesforce Functions login credentials, the connection process will complete. This can take up to a couple minutes. When the process successfully finishes, the Enable Functions button will no longer be present, and information about the connected Salesforce Functions account will be displayed in the Functions setup page.

Functions connected screenshot

If the connection process is not successful, error information will be displayed in the Functions setup page. You may attempt the process again by clicking Try Again, or contact Salesforce for help.

Authenticate CLI with Salesforce Functions

The Salesforce CLI also needs to be connected to the same Salesforce Functions account you used to connect your DevHub org. Connect your CLI using the following command:

This will open a browser page where you can log in to your Salesforce Functions account using the same credentials you used to connect your DevHub org.