A branch is an instant, isolated copy of your database. Branches share storage with their parent (copy-on-write), so they’re fast to create and cheap to maintain.
main (production)├── staging (instant copy of main)│ ├── feature-auth (copy of staging)│ └── feature-billing (copy of staging)└── dev-alice (copy of main)
// Create feature branch from stagingconst featureBranch = await client.database.v1.branches.create(projectId, { name: 'feature-user-auth', parentBranchId: stagingBranchId});// Developer works on their isolated copy// No risk of breaking staging or production
Test database migrations without risking production:
Copy
Ask AI
// 1. Create test branch from productionconst testBranch = await client.database.v1.branches.create(projectId, { name: 'migration-test'});// 2. Get connection to test branchconst testConn = await client.database.v1.projects.getConnection(projectId, { branch: 'migration-test'});// 3. Run migrations against test branch// If anything breaks, production is unaffected// 4. Once verified, run against production
1. main (production) │ ├─→ Create 'staging' from main │ │ │ ├─→ Create 'feature-x' from staging │ │ └─→ Develop, test, merge PR │ │ │ └─→ Create 'feature-y' from staging │ └─→ Develop, test, merge PR │ └─→ Deploy staging to production (main)
Branches use copy-on-write storage. A new branch only stores the differences from its parent, making them extremely fast to create and storage-efficient.