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.
- Audience
- New to running a server
- Last checked
- Steps
- 6
- Reading time
- 3 min
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 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 first.
- A Next.js app in a GitHub repository, with its
package.jsonin the top folder.
Steps
Step 1: Check the scripts in package.json
We run the
buildscript, then thestartscript. A new Next.js app already has both.next startlistens on the port in thePORTvariable, which we set for you.Keep your lockfile in the repository:
package-lock.json,pnpm-lock.yaml,yarn.lockorbun.lock. It tells us which package manager to use. To choose the Node.js version, setengines.nodeinpackage.jsonor add a.nvmrcfile.package.json { "scripts": { "dev": "next dev", "build": "next build", "start": "next start" }, "engines": { "node": "22" }}Note
If your
startscript sets a port, such asnext start -p 3000, remove-p 3000so the app usesPORT.Step 2: Connect the repository
Sign in at control.hostsrc.com (opens in a new tab) 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
On Variables, add what your app reads, one New variable each, or paste
NAME=valuelines 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 orDATABASE_URL.Press Save variables, then Deploy.
NEXT_PUBLIC_SITE_NAME=My appAPI_SECRET=paste-your-secret-hereNote
After you change a
NEXT_PUBLIC_variable, press Deploy again. The browser code only changes with a new build.Step 5: Give the app a web address
Open Settings, then Networking. Under Public networking, press Generate Domain. Check that the port is the one in Target port,
8080unless you changed it, then press Generate. The app gets an address onup.hostsrc.app, such asyour-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.
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.
Links
- Next.js deployment docs (external site, opens in a new tab)
how next build and next start work
- Hostsrc control panel (opens in a new tab)
sign in, then switch to Apps
- App hosting
plans and prices, with a link to order each plan
App hosting
Hobby €5/month
Includes €5 of usage every month. In beta. Final price, no VAT added.
Choose a planDiscord
Ask other admins and our team.
Join our Discord (external site, opens in a new tab)Related guides
How to deploy an app you built with AI
Push the code to GitHub, connect the repository once, add the app's variables and press Deploy. Every push after that deploys by itself.
7 steps5 min readNew to running a server
How to host a discord.py bot
Put the bot in a GitHub repository with requirements.txt, read the token from a variable, connect the repository and press Deploy.
7 steps4 min readNew to running a server
How to put a Discord bot online with App hosting
Add the bot's repository, save its token as a variable and press Deploy. A bot needs no web address. App hosting is in beta.
8 steps6 min readNew to running a server