Next.js
Deploy a Next.js app without a Dockerfile.
Teral builds Next.js apps automatically. It installs dependencies with the package manager of your lockfile, runs your build script and starts the app with your start script.
What your project needs
The scripts from create-next-app are all it takes:
{
"scripts": {
"build": "next build",
"start": "next start"
}
}next start listens on the PORT variable by itself, so the default port 8080 works without changes.
Pin the Node version with engines in package.json or an .nvmrc file, for example "engines": { "node": "22.x" }.
Variables
Variables are available during the build and at runtime. Keep in mind how Next.js uses them:
- Variables starting with
NEXT_PUBLIC_are written into the JavaScript bundle at build time. Changing one needs a new deployment, and its value is visible to anyone who loads your site. Never put secrets in them. - All other variables are only available on the server.
Different values for production and preview, such as a test API URL in preview, go into each environment's variables.
Monorepos
For an app in a subfolder, such as apps/web in a Turborepo or pnpm workspace:
- Set Root directory to the repository root,
., so workspace packages resolve, and set Build command to build only this app, such aspnpm turbo run build --filter=web. - Set Command to start it, such as
pnpm --filter web start.
Or keep the root directory at apps/web if the app doesn't depend on other packages in the repository.
Images and caching
next/image works out of the box. The image cache is kept on the instance's disk, which starts empty with every deployment and is limited to 128 MiB without storage. For many or large images, add storage or use an image CDN.