Next.js app
Next.js web app running in the sandbox using Node.js
Basic Next.js app with Tailwind and shadcn UI
The development server runs on port 3000 as soon as the sandbox is ready.
// template.ts
import { Template, waitForURL } from 'e2b'
export const template = Template()
.fromNodeImage('21-slim')
.setWorkdir('/home/user/nextjs-app')
.runCmd(
'npx [email protected] . --ts --tailwind --no-eslint --import-alias "@/*" --use-npm --no-app --no-src-dir'
)
.runCmd('npx [email protected] init -d')
.runCmd('npx [email protected] add --all')
.runCmd(
'mv /home/user/nextjs-app/* /home/user/ && rm -rf /home/user/nextjs-app'
)
.setWorkdir('/home/user')
.setStartCmd('npx next --turbo', waitForURL('http://localhost:3000'))// build.ts
import { Template, defaultBuildLogger } from 'e2b'
import { template as nextJSTemplate } from './template'
Template.build(nextJSTemplate, 'nextjs-app', {
cpuCount: 4,
memoryMB: 4096,
onBuildLogs: defaultBuildLogger(),
})