# How to deploy a Next.js app from GitHub

Connect the repository and press Deploy. We run your build and start scripts, next build and next start, and every push to GitHub deploys by itself.

Source: https://hostsrc.com/guides/deploy-nextjs-app-from-github. Last checked 2026-12-01, the day someone last followed the steps.

To deploy a Next.js app from GitHub, connect its repository in the control panel, press **Deploy**, then generate a web address. We run your `build` script and then your `start` script, which are `next build` and `next start` in a new Next.js app. After that, every push to GitHub deploys by itself.

You don't need a Dockerfile or any settings for a standard Next.js app.

> **On Hostsrc:** App hosting is in beta. [Order Hobby or Pro](/app-hosting#pricing) and **Apps** shows in the panel once your payment is confirmed. Final price, no VAT added.

## Before you start

- A Hostsrc account with App hosting turned on. It's in beta, so [order Hobby or Pro](/app-hosting#pricing) first.
- A Next.js app in a GitHub repository, with its `package.json` in the top folder.

## Steps

### Step 1: Check the scripts in package.json

Link to this step: https://hostsrc.com/guides/deploy-nextjs-app-from-github#step-1

We run the `build` script, then the `start` script. A new Next.js app already has both. `next start` listens on the port in the `PORT` variable, which we set for you.

Keep your lockfile in the repository: `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock` or `bun.lock`. It tells us which package manager to use. To choose the Node.js version, set `engines.node` in `package.json` or add a `.nvmrc` file.

```text title="package.json"
{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "engines": {
    "node": "22"
  }
}
```

> **Note:** If your `start` script sets a port, such as `next start -p 3000`, remove `-p 3000` so the app uses `PORT`.

### Step 2: Connect the repository

Link to this step: https://hostsrc.com/guides/deploy-nextjs-app-from-github#step-2

Sign in at [control.hostsrc.com](https://control.hostsrc.com) with your Hostsrc account. In the header, switch to **Apps**.

On **Projects**, press **New**, then **Connect GitHub**, and choose **GitHub**. GitHub asks which repositories to share: allow your app's repository. Back in Apps, press **New** again, choose **GitHub Repository** and pick it.

The panel makes a project named after the repository, with the app in it as a service. The service opens on **Variables**.

### Step 3: Add the variables

Link to this step: https://hostsrc.com/guides/deploy-nextjs-app-from-github#step-3

On **Variables**, add what your app reads, one **New variable** each, or paste `NAME=value` lines in **Raw editor**.

Next.js puts `NEXT_PUBLIC_` variables into the browser code while it builds. For those, switch **Build** on next to the variable. A variable with **Build** on is used only while building, not while the app runs. Leave **Build** off for server secrets, such as an API key or `DATABASE_URL`.

Press **Save variables**, then **Deploy**.

```text
NEXT_PUBLIC_SITE_NAME=My app
API_SECRET=paste-your-secret-here
```

> **Note:** After you change a `NEXT_PUBLIC_` variable, press **Deploy** again. The browser code only changes with a new build.

### Step 4: Watch the build

Link to this step: https://hostsrc.com/guides/deploy-nextjs-app-from-github#step-4

Open **Deployments**. The new deployment shows **BUILDING** while we install the packages and run `next build`, and **ACTIVE** once `next start` runs. Press **View logs** to follow the build. We keep the Next.js build cache between builds, so later builds are usually quicker.

### Step 5: Give the app a web address

Link to this step: https://hostsrc.com/guides/deploy-nextjs-app-from-github#step-5

Open **Settings**, then **Networking**. Under **Public networking**, press **Generate Domain**. Check that the port is the one in **Target port**, `8080` unless you changed it, then press **Generate**. The app gets an address on `up.hostsrc.app`, such as `your-app-production.up.hostsrc.app`.

To use your own domain, press **Custom Domain**, type the domain and press **Add domain**. Add the DNS record the panel shows at your domain's provider, then press **Check now**. The domain shows **Live** once HTTPS is set up.

### Step 6: Push to update the app

Link to this step: https://hostsrc.com/guides/deploy-nextjs-app-from-github#step-6

Every push to the repository's branch builds and deploys by itself.

If a change breaks something, open **History** on **Deployments** and open an earlier deployment. Choose **Rollback to this** in its menu and confirm with **Roll back**.

## Troubleshooting

### The page shows an old value of a NEXT_PUBLIC_ variable

`NEXT_PUBLIC_` values are fixed when the app builds. Check that **Build** is on for the variable, save, and press **Deploy**.

### The deploy fails because the app is not ready

The app didn't answer on its port. Check that the `start` script is `next start` with no `-p`, so it uses `PORT`. If you changed **Target port** in **Settings**, the address must use the same port.

### My app uses output: 'export'

With `output: 'export'` in `next.config.js`, Next.js builds a static site into the `out` folder, and we serve those files. There is no `next start`, so server features such as API routes don't run. Remove `output: 'export'` if you need them.

### The build fails

Open the failed deployment and read its build logs. The last lines name the problem. A build that passes on your computer can fail here if a variable it needs at build time doesn't have **Build** on.

## Related guides

- [How to deploy an app you built with AI](https://hostsrc.com/guides/deploy-ai-built-app)
- [How to host a discord.py bot](https://hostsrc.com/guides/host-discord-py-bot)
- [How to put a Discord bot online with App hosting](https://hostsrc.com/guides/discord-bot-app-hosting)

## Links

- [Next.js deployment docs](https://nextjs.org/docs/app/getting-started/deploying): how next build and next start work
- [Hostsrc control panel](https://control.hostsrc.com): sign in, then switch to Apps
- [App hosting](https://hostsrc.com/app-hosting): plans and prices, with a link to order each plan
