E2B Sandbox Setup
ZapDev uses E2B Code Interpreter to run AI-generated code in isolated sandboxes. Before running the application, you must build a custom E2B template that contains the framework environment.Prerequisites
- Docker Desktop or Docker Engine installed and running
- E2B account (free tier available)
- Node.js 18+ or Bun installed
Installation
Install the E2B CLI globally using your preferred package manager:Authentication
Log in to your E2B account to authenticate the CLI:Building the Next.js Template
ZapDev includes pre-configured sandbox templates for multiple frameworks. The primary template is for Next.js.Navigate to Template Directory
Build the Template
your-template-name with a unique identifier (e.g., zapdev-nextjs-prod).
The
--cmd "/compile_page.sh" flag tells E2B to run the startup script that pre-warms the Next.js dev server and ensures the root page is compiled.Template Build Process
The template build includes:- Base Image: Node.js 21 slim image
- User Setup: Creates
useraccount with proper permissions - Dependencies: Installs npm, pnpm, and system utilities (curl, sudo)
- Next.js App: Scaffolds a fresh Next.js 15.3.3 application
- Shadcn/ui: Initializes Shadcn with neutral theme and installs all components
- Startup Script: Copies
compile_page.shfor pre-warming the dev server
What’s in compile_page.sh?
The startup script ensures the sandbox is ready for instant code generation:Configuring Your Application
After building the template, you need to update the template name in your code:Update Inngest Functions
Editsrc/inngest/functions.ts and replace the default template name:
Set E2B API Key
Add your E2B API key to.env:
Available Framework Templates
ZapDev supports multiple framework templates insandbox-templates/:
- nextjs - Next.js 15 with Shadcn/ui (primary)
- angular - Angular 19 with Material Design
- react - React 18 with Vite and Chakra UI
- vue - Vue 3 with Vuetify
- svelte - SvelteKit with DaisyUI
e2b template build command.
Template Management
List Your Templates
Delete a Template
Update a Template
To update an existing template, rebuild it with the same name:Troubleshooting
Docker Not Running
If you see errors about Docker during the build:Build Timeout
If the build times out during npm installations:- Increase the timeout in
e2b.toml.old(if using legacy config) - Check your internet connection
- Try building during off-peak hours
Sandbox Start Failures
If sandboxes fail to start or the preview doesn’t load:- Verify the template name matches in your code
- Check E2B Dashboard for sandbox logs
- Rebuild the template with
--cmd "/compile_page.sh" - Ensure your E2B API key is valid and not rate-limited
Next Steps
- Configure Inngest for background job processing
- Set up Clerk Authentication
- Deploy to production on Vercel