Unlocked packages let you deploy modular, editable Salesforce metadata across orgs — great for internal apps and fast iterations.
What are unlocked packages?
Unlocked packages are a 2nd-generation packaging option in Salesforce that provide modularity and flexibility. They let teams bundle metadata (Apex, LWC, objects, etc.) into versioned packages that can be upgraded while still allowing administrators or developers to modify components post-installation.
Key benefits
- Flexibility to edit components after installation
- Modularity for clearer architecture and reuse
- Versioning and upgrade capabilities
- Better collaboration across developer teams
Step-by-step: Create an unlocked package
Follow these steps in a Dev Hub-enabled org and with the Salesforce CLI installed.
1. Enable Dev Hub
Navigate to Setup > Dev Hub and enable Dev Hub and 2nd Generation Managed Packaging (2GP) in your org.
2. Install Salesforce CLI
Download and install the Salesforce CLI from the official site to run packaging and org management commands from your terminal.
3. Authenticate with your Dev Hub
sfdx force:auth:web:login -d -a DevHub
4. Create the unlocked package
sfdx force:package:create --name MyPackage --description "My First Package" --packagetype Unlocked --path force-app --nonamespace --targetdevhubusername DevHub
5. Create a package version
sfdx force:package:version:create -p MyPackage -d force-app -k mysecretkey --wait 10 -v DevHub --codecoverage
Use a secure install key (-k) if you want to require a password during installation.
6. Install the package in a target org (optional)
Use the install URL shown after creating a version, or run the CLI install command and provide the install key if configured.
Best practices
- Use a single namespace only when needed.
- Track changes made directly in production — use source control.
- Test thoroughly before upgrading production orgs.
- Monitor and manage dependencies between components.
- Implement CI/CD (Jenkins, GitHub Actions, GitLab CI) for automated builds and tests.
FAQs
Unlocked packages differ from managed and unmanaged packages by offering both upgradeability and post-installation editability. They provide a middle ground enabling internal teams to ship modular solutions while retaining flexibility.
Why this matters: Unlocked packages help Salesforce admins, developers, and architects move faster, enforce modular design, and adopt continuous delivery patterns — reducing risk during deployments and enabling rapid iteration.








Leave a Reply