Unlocked packages let you modularize, version, and deploy Salesforce metadata while still allowing post-install edits — ideal for internal applications and rapid iteration.
What are unlocked packages?
Unlocked packages are a 2nd-Generation Packaging (2GP) option that provide modularity, upgradability, and the ability to edit components after installation. They’re particularly useful for teams that need to deliver and iterate internal applications across multiple Salesforce orgs.
Benefits
- Flexibility: Modify metadata after installation.
- Modularity: Group related components for clean delivery.
- Upgradability: Publish new package versions while preserving local edits when managed correctly.
Step-by-step: Create an unlocked package
Follow these hands-on steps to create and install an unlocked package. Commands below assume you have Salesforce CLI installed.
1. Enable Dev Hub
In the org that will act as your Dev Hub: Setup → Dev Hub. Enable Dev Hub and 2nd Generation Managed Packaging (2GP).
2. Install Salesforce CLI
Download and install the Salesforce CLI from the official site. The CLI provides the packaging, authentication, and deployment commands you’ll use.
3. Authenticate with your Dev Hub
sfdx force:auth:web:login -d -a DevHub
4. Create an unlocked package
sfdx force:package:create --name MyPackage --description "My First Package" --packagetype Unlocked --path force-app --nonamespace --targetdevhubusername DevHub
Adjust –name, –path, and namespace flags as needed.
5. Create a package version
sfdx force:package:version:create -p MyPackage -d force-app -k mysecretkey --wait 10 -v DevHub --codecoverage
Replace mysecretkey with a secure install key if required. The command will compile and build a package version; use –wait to allow time for completion.
6. Install the package in a target org (optional)
- Use the installation URL provided after version creation or run installation commands via CLI.
- Provide the installation key when prompted and choose installation scope (All Users / Admins Only).
Best practices
- Use namespaces only when necessary to avoid upgrade complexity.
- Track local changes using Git and enforce branching strategies for safe upgrades.
- Test new package versions in sandboxes or scratch orgs before production deployment.
- Monitor dependencies between components to avoid upgrade conflicts.
- Automate CI/CD (Jenkins, GitHub Actions, GitLab CI) to build, test, and publish package versions reliably.
Quick FAQ
How do unlocked packages differ from managed/unmanaged? Managed packages are vendor-controlled and can be locked, unmanaged packages are one-time exports without upgrade paths, while unlocked packages provide upgradeable packages that remain editable post-installation.
Why this matters
Unlocked packages give Salesforce teams a powerful way to scale application development, maintain version control, and deploy changes across multiple orgs without sacrificing the ability to adapt in production. For admins and developers, they enable modular design, safer upgrades, and smoother collaboration across teams.
Key takeaways:
- Enable Dev Hub and use SFDX to create package artifacts.
- Leverage source control and CI/CD to protect local changes and automate releases.
- Test thoroughly and monitor dependencies to prevent upgrade issues.
For Salesforce admins, developers, and business users, unlocked packages streamline deployment workflows and reduce friction when delivering iterated business features across environments.





Leave a Reply