# How to deploy a Next.js app

Deploy a Next.js app to Ample with your coding agent, the CLI or MCP, using build and start commands verified on November 6, 2026.

## the short version

To deploy a Next.js app on Ample, run `ample deploy . --name <app-name> --public` in the project directory, or ask your coding agent to deploy it to Ample. Ample builds it on the node-22 template, starts it with `npm run start` and returns a public HTTPS URL.

## Deploy Next.js

1.  **Ask your coding agent.** Install the Ample CLI and create an account, then ask your agent: "Deploy this Next.js app to Ample".

```
    $ curl -fsSL https://get.ample.computer/install.sh | sh
    $ ample auth signup
    ```

2.  **Or deploy from the CLI.** It waits until the app is live or failed and prints the URL.

```
    $ ample deploy . --name <app-name> --public
    ```

3.  **Or use MCP.** Call `ample_deploy` on `https://api.ample.computer/mcp` (or `ample mcp` over stdio).

4.  **Verify.** On failure read `ample logs <deployment_id> --kind build`, fix the cause and deploy again.

## Tested configuration

|     |     |
| --- | --- |
| Template | `node-22` |
| Install | `npm install` |
| Build | `npm run build --if-present` |
| Start | `npm run start` |
| Tested size | `s-1vcpu-1gb` |

Last verification (2026-11-06): Next.js 15 SSR app (next build, next start) deployed on node-22; the page and an API route served correctly.

## You need

- A `package.json` with build and start scripts (`next build`, `next start -H 0.0.0.0 -p ${PORT:-3000}`)
- Node 22 compatible dependencies
- An Ample account token with `servers:write`

## Know the limits

- Verified on the node-22 template at `s-1vcpu-1gb`.
- Tested with Next.js 15 (`next build`, `next start`).

## Move a Next.js app to Ample

- [How to move a Next.js app from AWS EC2 to Ample](/content/migrate/aws-ec2-app/next-js/index.html)
- [How to move a Next.js app from DigitalOcean Droplet to Ample](/content/migrate/digitalocean-droplet-app/next-js/index.html)
- [How to move a Next.js app from Fly.io to Ample](/content/migrate/fly-io-app/next-js/index.html)
- [How to move a Next.js app from Heroku to Ample](/content/migrate/heroku-app/next-js/index.html)
- [How to move a Next.js app from Netlify to Ample](/content/migrate/netlify-web-app/next-js/index.html)
- [How to move a Next.js app from Railway to Ample](/content/migrate/railway-app/next-js/index.html)
- [How to move a Next.js app from Render web service to Ample](/content/migrate/render-web-service/next-js/index.html)
- [How to move a Next.js app from Vercel to Ample](/content/migrate/vercel-app/next-js/index.html)

## Frequently asked questions

### Do I need a Dockerfile to deploy Next.js?

No Dockerfile needed: Ample Computer detects Next.js from the repository and builds it from source on the `node-22` template.

### How do I add a database to a Next.js app?

Leave `DATABASE_URL` unset and deploy: when the code needs Postgres, MySQL, Redis or MongoDB, Ample creates a managed database and passes its connection string to the app. See [Connect Postgres for Next.js](/content/guides/next-js/database-connection/index.html).

### What if the deploy fails?

`ample deploy` waits until the app is live or failed. A failure returns who must act, a diagnosis and a suggested fix; read the logs with `ample logs <deployment_id> --kind build`. See [Diagnose deployment failures for Next.js](/content/guides/next-js/deployment-diagnostics/index.html).

## More for Next.js

- [How to serve Next.js public assets through a CDN on Ample](/content/guides/next-js/cdn-assets/index.html): Deliver public assets for a Next.js app through the Ample CDN
- [How to set environment variables and secrets for a Next.js app on Ample](/content/guides/next-js/configuration-secrets/index.html): Configure environment variables and secrets for a Next.js app on Ample
- [How to connect a Next.js app to Postgres on Ample](/content/guides/next-js/database-connection/index.html): Connect a Next.js app to PostgreSQL on Ample from a route handler
- [How to fix a failed Next.js deploy on Ample](/content/guides/next-js/deployment-diagnostics/index.html): Diagnose a failed Next.js deployment on Ample
- [How to use S3-compatible storage from a Next.js app on Ample](/content/guides/next-js/object-client/index.html): Configure S3-compatible access for a Next.js app on Ample
- [How to serve private files from a Next.js app on Ample](/content/guides/next-js/private-file-access/index.html): Enforce private-file authorization in a Next.js app on Ample
- [How to run database migrations for a Next.js app on Ample](/content/guides/next-js/schema-changes/index.html): Schema changes for a Next.js app on Ample
