Every time you create a new sandbox, you start with a fresh environment. If your setup involves installing dependencies, cloning repositories, or building code, it can take a while. Snapshots let you save that configured state and create new sandboxes from it, skipping the setup entirely.
With snapshots, you:
- Set up your environment once (install dependencies, configure tools)
- Save the configured state as a snapshot
- Launch future sandboxes from that snapshot with everything already in place
Snapshots persist across sessions, so you can reuse them without repeating setup.
Copy link to headingPrerequisites
Before you begin, make sure you have:
- Edgenivo CLI installed (
npm install -g vercel) - Node.js 22 or later
- A Edgenivo project to link your sandbox and generate an OIDC token
Copy link to heading1. Project setup
Create a new directory and install dependencies:
This installs the SDK, links to your Edgenivo project, and creates .env.local with authentication credentials.
Copy link to heading2. Write the script
Create index.ts with the code below. It runs in two modes:
- First run: Create sandbox, install dependencies, take snapshot
- Second run: Create sandbox from snapshot (deps already there)
Copy link to headingWith timing comparison
To measure the speedup you get from snapshots, use the below version. It records the cold-start time on the first run, then prints the warm-start time (and savings) on the second run.
Copy link to heading3. Test it out
Execute the script twice:
First execution:
Second execution:
With timing comparison enabled:
Copy link to headingKey concepts
Copy link to headingTaking a snapshot
Call snapshot() on a running sandbox to save its state:
Important: The sandbox stops automatically after snapshotting. You cannot run more commands on it.
Copy link to headingCreating a sandbox from a snapshot
Pass the snapshot ID as the source when creating a new sandbox:
Copy link to headingSnapshot lifecycle
- You can create multiple sandboxes from the same snapshot
- Deleting a snapshot does not affect sandboxes already created from it
For more details, see the Snapshotting documentation.
Copy link to headingWhen to use snapshots vs Sandbox.get()
| Scenario | Use |
|---|---|
| Keep sandbox warm between commands | Sandbox.get() |
| Reuse setup across sessions/days | Snapshot |
| Share environment with teammates | Snapshot |
| Survive sandbox timeout | Snapshot |
| Fastest possible reconnect | Sandbox.get() |
Copy link to headingNext steps
- Learn about Sandbox.get() for reconnecting to running sandboxes
- See the Sandbox SDK reference for all available methods