What happens inside a sandbox
When a session starts, the sandbox goes through these steps:- Clone — clones the Expo template from
https://github.com/sa4hnd/expo-template - Install — runs
npm installto install JS dependencies - Start dev server — starts
npx expo start --tunnel --port 3000 - Create tunnel — Expo creates a public tunnel URL for the phone preview
- Run agent — the AI agent generates code by editing files in the sandbox
- Stream updates — file changes are streamed back to Convex in real time
AUTO_PAUSE_TIMEOUT_MS).
Build the template
Authenticate with E2B
Navigate to the template directory
Dockerfile that defines the sandbox environment — the base OS, installed tools, and any pre-installed dependencies.Build and publish the template
Set the template ID in config
Open Also update
vibracode-backend/config.ts and replace YOUR_E2B_TEMPLATE_ID with your template ID:vibracode-backend/lib/e2b/config.ts with the same template ID if it has a separate reference.Set the E2B API key
Make sure Get your API key from the E2B dashboard.
E2B_API_KEY is set in your vibracode-backend/.env.local:Sandbox lifecycle
Configuration reference
These settings control sandbox behavior invibracode-backend/.env.local:
| Variable | Default | Description |
|---|---|---|
E2B_API_KEY | — | Required. Your E2B API key. |
AUTO_PAUSE_TIMEOUT_MS | 600000 | Milliseconds of inactivity before a sandbox auto-pauses. Default is 10 minutes. |
Rebuilding the template
If you change theDockerfile or want to update system dependencies in the sandbox, run e2b template build again. You’ll get a new template ID — update config.ts and redeploy your backend.
Next steps
- Backend setup — deploy the backend that uses this template
- Environment variables reference — full list of E2B-related variables