Create Developer Hub and Namespace Orgs

Link a Developer Hub to a namespace org to use the Salesforce Developer Experience to develop a second-generation package.

  1. Create an org with Dev Hub features enabled.

    1. Create a Developer Edition org.

    2. Enable Lightning Experience.

    3. Enable Dev Hub features: From Setup, enter Dev Hub in the Quick Find box and select Dev Hub. Then, click Enable. After you enable Dev Hub, you can’t disable it.

    4. Enable Unlocked Packages and Second-Generation Managed Packages.

  2. Create a namespace org.

    1. Create a Developer Edition org.

    2. Enable Lightning Experience.

    3. Create a namespace.

      Choose your namespace carefully. If you’re trying out this feature or need a namespace for testing purposes, choose a disposable namespace. Don’t choose a namespace that you want to use in the future for a production org or some other real use case. After you associate a namespace with an org, you can’t change it or reuse it.

      Note

    4. In the Dev Hub org, use Namespace Registry to register the namespace that you created. To learn more, see Link a Namespace to a Dev Hub Org.

    5. In the sfdx-project.json file, specify your namespace using the namespace attribute.

  3. Create an external client app in your Dev Hub org for authorization. The app allows you to set the refresh token timeout, specify IP ranges, and more. Use any name; for example, Dev Hub ECA.

    We recommend using an external client app for authorization instead of a connected app. Starting in Spring ’26, customers can’t create a connected app unless they request the ability to create connected apps from Salesforce Support. To migrate a preexisting connected app, see Create an External Client App from a Connected App.

    Note

  4. To authenticate into the dev hub, use the following Salesforce CLI command. For HUB_ORG_ALIAS, choose any name. For CLIENT_ID, use the consumer key. For INSTANCE_URL, use https://login.salesforce.com. (To find the consumer key, see Step 5.)

    1sf org login web --set-default-dev-hub --alias [HUB_ORG_ALIAS] --client-id [CLIENT_ID] —instance-url [INSTANCE_URL]
  5. You are prompted for the external client app secret. To retrieve it and the consumer key:

    1. From Setup, enter External Client App Manager in the Quick Find box and click External Client App Manager.

    2. Select the external client app for your integration.

    3. On the Settings tab, open the OAuth Settings section and click Consumer Key and Secret.

    4. Verify your identity with the verification code sent to the email address of your Salesforce account.

    5. Copy the consumer key and secret.