Skip to content
← Back to all articles

Packages · Free setup

Create a Free Salesforce Managed Package: Complete Setup Checklist

A free, end-to-end checklist for building a second-generation managed package and giving people a Salesforce install link.

Cost: The tools, Developer Edition orgs, package creation, and testing steps in this guide can be done for free. Anyone who installs the package still needs their own Salesforce org and the appropriate Salesforce licenses. Free Developer Edition Dev Hubs can expire from inactivity, so treat one as a learning setup rather than a guaranteed permanent home for a customer package.

This guide walks through a second-generation managed package (2GP), the Salesforce package type intended for distributing an app to customer orgs. You will create a Dev Hub, set aside a namespace, build the app in a local Salesforce DX project, create a version, test it in a clean org, and publish a Salesforce install link on your website.

What you need: a computer that can run VS Code and Salesforce CLI, internet access, and a Salesforce login. The instructions use free Developer Edition and scratch orgs for learning and testing.

Checklist step 1

Choose and create your Dev Hub org

Illustration for choose and create your dev hub org: Create a free Developer Edition org; then Enable Dev Hub in Setup; then The Dev Hub owns the package
Create a free Salesforce Developer Edition org and enable Dev Hub plus second-generation packaging. This org owns the package versions, so keep it active.
  • Sign up for a free Salesforce Developer Edition org. This will be your learning Dev Hub.
  • In that org, open Setup and search for Dev Hub.
  • Select Enable Dev Hub, then enable Unlocked Packages and Second-Generation Managed Packages.
  • Keep the org active and secure. It owns every managed 2GP package created from it, and enabling these settings cannot be undone.

Salesforce currently limits a Developer Edition Dev Hub to six scratch orgs and package versions per day and three active scratch orgs. Developer Edition orgs can expire after inactivity; if the Dev Hub expires, you can lose access to its packages and package updates.

Checklist step 2

Reserve a namespace

Illustration for reserve a namespace: Reserve a unique namespace; then Register it with Dev Hub; then Choose before package creation
Create a namespace in a Developer Edition org, then link it to your Dev Hub in Namespace Registry. Choose carefully: a managed package cannot later change its namespace.
  • Sign up for a second free Developer Edition org to reserve the namespace.
  • In the namespace org, go to Setup → Package Manager → Namespace Settings → Edit.
  • Enter an available namespace and save it.
  • In your Dev Hub, open Setup → Namespace Registry and link the namespace to the Dev Hub.
  • Keep the namespace org login. Choose the namespace before creating a package; you cannot change the namespace on the package later.

For a managed package, this prefix becomes part of the names of your custom Salesforce components. Use a name you are comfortable keeping long term.

Checklist step 3

Install the free development tools

Illustration for install the free development tools: Get the editor; then Install the Salesforce CLI; then Add Salesforce tools
Install Visual Studio Code, Salesforce CLI, and the Salesforce Extension Pack. VS Code and the CLI are free downloads. Salesforce CLI is required even when you mostly use the VS Code interface.
  • Download and install Visual Studio Code for Windows, macOS, or Linux.
  • Install the Salesforce CLI.
  • In VS Code, open Extensions and install Salesforce Extension Pack from the Marketplace.
  • Open VS Code’s integrated terminal and verify that the CLI installed:
sf --version

Illustration of the public VS Code download page with Windows, macOS, and Linux download choices; select to open the official installer pageOfficial installer page
Choose the download that matches your computer. The page illustration links to Microsoft’s public download page; choose the installer for your operating system there.

VS Code’s Salesforce extensions use Salesforce CLI behind the scenes, so install the CLI even if you plan to use VS Code menus for most tasks.

Checklist step 4

Create the local Salesforce DX project

Illustration for create the local salesforce dx project: Generate a DX project; then Keep source in the project; then Set the namespace
Create a standard project in VS Code or from the terminal. The project folder stores the metadata and code that will become your package. Add the namespace reserved earlier to the project configuration.
  • In VS Code, open the Command Palette and run SFDX: Create Project.
  • Choose Standard, enter a project name, and select a folder.
  • Alternatively, use these terminal commands:
sf project generate --name MySalesforceApp
cd MySalesforceApp
  • Open sfdx-project.json and add your namespace as a top-level property, preserving the rest of the file:
"namespace": "your_namespace"

Replace your_namespace with the namespace you reserved. A DX project contains your source files; it is not itself the installable package.

Checklist step 5

Authorize the Dev Hub from the CLI

Illustration for authorize the dev hub from the cli: Start browser sign-in; then Approve Salesforce CLI; then Check authorized orgs
From the project folder, sign in to the Dev Hub through the browser flow and make it the default Dev Hub. Confirm that Salesforce CLI can see it.
  • From the Salesforce DX project folder, start the browser-based Dev Hub sign-in:
sf org login web --alias DevHub --set-default-dev-hub
  • In the browser, log in to the Dev Hub and approve Salesforce CLI access.
  • Confirm that the org is authorized:
sf org list
Checklist step 6

Create a development scratch org

Illustration for create a development scratch org: Dev Hub creates a scratch org; then Build and iterate there; then Deploy local source
Create a temporary scratch org from the project definition. Use it to build and iterate on your app. Scratch orgs are free but have daily and active-org limits.
  • Use the project’s config/project-scratch-def.json file. It defines the scratch org edition and features.
  • Create a temporary development org:
sf org create scratch --definition-file config/project-scratch-def.json --alias DevScratch --target-dev-hub DevHub --duration-days 30 --wait 10 --set-default
  • Open the new org:
sf org open --target-org DevScratch

Scratch orgs are disposable. Their availability is subject to the Dev Hub’s limits, and each scratch org expires after its selected duration.

Checklist step 7

Build the app and keep its source

Illustration for build the app and keep its source: Add only app components; then Keep files in force-app; then Review the package contents
Create your Salesforce components in the project or build them in the development org and retrieve the metadata. Keep the files you intend to distribute in the package directory, usually force-app. Leave unrelated org configuration out.
  • Build the objects, fields, flows, Apex, Lightning components, and other features that make up your app.
  • You can author source in VS Code and deploy it to the development scratch org, or build in the org and retrieve its metadata into the project.
  • Keep the components you intend to distribute in the package directory, normally force-app.
  • Leave unrelated setup, test data, and experimental components out of the package.
  • For an installable result, test dependencies and permissions as well as the feature itself.

The project files become the input for package creation. Keep them in source control when you are ready to maintain versions over time.

Checklist step 8

Create the managed package

Illustration for create the managed package: Name the package; then Choose Managed; then Create in the Dev Hub
Create the 2GP managed package from the project directory. This creates the package container in the Dev Hub and records its details in sfdx-project.json. Check its name, namespace, and managed type before continuing.
  • From the project directory, create the managed package container:
sf package create --name MySalesforceApp --package-type Managed --path force-app --target-dev-hub DevHub
  • Save the package ID and alias returned by the CLI.
  • Review sfdx-project.json; Salesforce adds the package details there.
  • Confirm the package name, namespace, and managed type before moving on.

The package’s namespace and type cannot be changed after the package is created.

Checklist step 9

Build a beta package version

Illustration for build a beta package version: Snapshot the source; then Validate dependencies; then Save the 04t version ID
Create a version from the package files. The returned 04t ID identifies the installable package version. Beta versions are for scratch org and sandbox testing. If the package has Apex, enable code coverage and meet Salesforce’s release coverage requirements.
  • In sfdx-project.json, set the package version number, for example 1.0.0.NEXT, in the package directory entry.
  • Create a beta version:
sf package version create --package MySalesforceApp --installation-key-bypass --code-coverage --wait 30 --target-dev-hub DevHub
  • The CLI returns a package-version ID beginning with 04t. Save it; it identifies this exact installable snapshot.
  • If the command returns a creation request ID beginning with 08c before it finishes, check the request:
sf package version create report --package-create-request-id 08cXXXXXXXXXXXX

--installation-key-bypass means an installer does not need a separate package password. If you want to restrict installation, use an installation key instead. The --code-coverage flag validates package coverage for release. If the package contains Apex, its tests must meet Salesforce’s minimum coverage requirement before promotion.

Checklist step 10

Install and test in a clean target org

Illustration for install and test in a clean target org: Create a no-namespace org; then Install the beta version; then Check setup and permissions
Create a separate scratch org without a namespace to simulate a subscriber org. Install the beta package there and test it as a clean user would. Salesforce package versions and scratch orgs are free within the available limits.
  • Create a second scratch org with no namespace to represent a clean subscriber org:
sf org create scratch --definition-file config/project-scratch-def.json --alias SubscriberTest --target-dev-hub DevHub --duration-days 30 --no-namespace --wait 10
  • Install the beta version using its 04t ID:
sf package install --package 04tXXXXXXXXXXXX --target-org SubscriberTest --wait 30 --no-prompt
  • Open the test org, assign the required permission set, and test the app as a normal user.
  • Check that the package installs cleanly and that the expected setup, permissions, and features work.
  • Fix problems in the source and create a new version to retest.

Beta versions can be installed in scratch orgs and sandboxes, but not production orgs. Use a disposable target for beta testing.

Checklist step 11

Release the version and publish its link

Illustration for release the version and publish its link: Promote the tested version; then Build the Salesforce install URL; then Add it to your site
When the clean-org test passes, promote the tested version to Released. Promotion cannot be undone for that version. Use the 04t ID in Salesforce’s install URL and put that URL behind your website button. The package is stored by Salesforce; your site hosts the page and link.
  • When the clean-org test passes, promote the tested version from beta to released:
sf package version promote --package 04tXXXXXXXXXXXX --target-dev-hub DevHub
  • Confirm the version is released. Promotion is permanent for that package version.
  • In the Dev Hub, copy your My Domain hostname, then replace the placeholders in this URL with your Dev Hub My Domain and the released version’s 04t ID:
https://YOUR-DEV-HUB-MY-DOMAIN.lightning.force.com/packagingSetupUI/ipLanding.app?apvId=04tXXXXXXXXXXXX
  • Open the link while signed in to SubscriberTest to verify that Salesforce opens the installer for the intended package.
  • Put that URL behind an Install in Salesforce button on your website.

Salesforce stores and serves the managed package version. Your website only needs the article or app page and the install link. Anyone with the URL and a valid Salesforce login can open the installer; the installing user chooses the target org and confirms the install.

Official downloads and references

Salesforce org editions, command flags, and distribution policies can change. Check Salesforce’s current documentation before using this process for a commercial release. A free Developer Edition org is useful for learning, but Salesforce warns it can expire and affect long-term access to packages it owns.

Browse all articles