> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slipway.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy a Next.js app

> Deploy a Next.js app with server rendering and a live URL.

Next.js runs on slipway as a `web` service on the Node runtime, with no Dockerfile needed.

## Prerequisites

A Next.js app in a GitHub or GitLab repository, with `next build` and `next start` working
locally.

## Configure the app

Next.js binds to `0.0.0.0` and reads `PORT` when told to. Set the start script:

```json package.json theme={"system"}
{
  "scripts": {
    "build": "next build",
    "start": "next start -H 0.0.0.0 -p ${PORT:-3000}"
  }
}
```

Next.js checks the `Host` header on server actions. Set `allowedOrigins` so slipway's
hostname is accepted:

```javascript next.config.js theme={"system"}
module.exports = {
  experimental: {
    serverActions: {
      allowedOrigins: [process.env.APP_HOST].filter(Boolean)
    }
  }
};
```

## Add slipway.yaml

```yaml slipway.yaml theme={"system"}
version: 1

services:
  - name: web
    runtime: node
    runtimeVersion: "22"
    buildCommand: npm ci && npm run build
    command: ["npm", "start"]
    ports:
      - port: 3000
        public: true
    healthCheckPath: /
    env:
      NODE_ENV: production
      APP_HOST: ${service.web.host}
```

## Deploy

Select **New**, choose your repository, keep the tracked branch, and deploy. The service's
Logs tab opens on the first build; when the status reaches `healthy` the service header
shows the URL.

Pushes to the tracked branch redeploy automatically.

## Add a database

```yaml slipway.yaml theme={"system"}
databases:
  - name: db
    engine: postgres
    diskSizeGB: 10

services:
  - name: web
    runtime: node
    env:
      DATABASE_URL: ${service.db.url}
```

`${service.db.url}` resolves at deploy time, so no connection string is committed. See
[Databases](/slipway-yaml/databases).

## Static export instead

If you use `output: 'export'`, deploy it as a static site with no container and no compute
charge:

```yaml slipway.yaml theme={"system"}
version: 1

services:
  - name: site
    type: static
    runtime: node
    buildCommand: npm ci && npm run build
    publish: out
    notFound: /404.html
```

See [Static sites](/services/static).

## Next steps

> **[Secrets](/slipway-yaml/secrets-and-variables)**
>
> Keep API keys out of the repository.

> **[Custom domains](/networking/domains)**
>
> Serve under your own zone.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.