Sub topic 8
Scratch Orgs and Developer Edition Orgs
This chapter assumes you know what an org is and have seen the main org types: production, sandbox, scratch, Developer Edition, and trial. Here you will look at the two orgs developers use most for building and testing: scratch orgs and Developer Edition orgs.
Developer Edition orgs
A Developer Edition (DE) org is a free, standalone org you sign up for. It is not copied from production. It starts with a fixed set of features and limits, and it stays available as long as you keep logging in.
Use a DE org to:
- Learn the platform without touching a company's data.
- Try a feature before you propose it at work.
- Build a personal project or a prototype.
A DE org has low storage and API limits compared with paid editions. It is not meant to hold real business data. Changes you make there do not flow to production on their own. You must move them yourself, for example as a deployment from your project.
Scratch orgs
A scratch org is a temporary org that you create from a configuration file. It is disposable by design. You create one, deploy your code and configuration to it, test, and then delete it or let it expire.
Scratch orgs are created with the Salesforce CLI and need a Dev Hub. A Dev Hub is an org with the Dev Hub feature turned on. It tracks the scratch orgs you create and enforces how many you can have.
Key properties:
- They are defined by configuration, not copied from production.
- They have a lifespan of 1 to 30 days. The default is 7.
- They start empty, with no data from any other org.
- You can create many of them, within the Dev Hub's limits.
The definition file
The definition file describes the org you want. This minimal example requests a Developer edition scratch org.
{
"orgName": "Tutorial Scratch Org",
"edition": "Developer"
}Save it as config/project-scratch-def.json inside a Salesforce DX project. Then create the org:
sf org create scratch --definition-file config/project-scratch-def.json --alias tutorial-scratch --duration-days 7The --alias option gives the org a short name. The --duration-days option sets how long it lives. After seven days it is deleted automatically.
Comparing the two
| Feature | Scratch org | Developer Edition org |
|---|---|---|
| Cost | Included with the Dev Hub's allowance | Free |
| Lifespan | 1 to 30 days | Long-lived while you log in |
| Created by | CLI and a definition file | Web sign-up |
| Starting state | Empty, shaped by configuration | Fixed default setup |
| Best for | Repeatable development and automated tests | Learning and experiments |
Common errors
- No Dev Hub.
sf org create scratchfails if you have not authorized a Dev Hub. Authorize one first and set it as the default. - Expecting data. Scratch orgs have no records. Load sample data with a script or a data file.
- Treating a scratch org as storage. Its configuration is the source of truth. Keep that configuration in version control, not in the org.
- Hitting the limit. Dev Hubs cap the number of active scratch orgs. Delete the ones you no longer need.
Exercise
A teammate wants to test a change against a clean org that matches the project's configuration, then throw the org away. Should they use a scratch org or a Developer Edition org, and what do they need first?
Show answer
A scratch org. It is created from a definition file, starts clean, and expires on its own. They need a Dev Hub org authorized in the Salesforce CLI.