Deploy a Next.js app from GitHub to the Mumbai region
Connect GitHub, review the build settings DASTER detects, deploy to Development and promote the same image to Production, in Mumbai.
Published · DASTER
Last updated
To deploy a Next.js app from GitHub on DASTER, connect GitHub, pick the repository in Deploy an app, check the commands DASTER detects (npm install, npm run build, npm start), set the port to 3000 and deploy to Development. The app runs in Mumbai at https://<app id>.apps.daster.io, and you can promote the same image to Production.
DASTER Hosting runs apps in Mumbai (ap-south-1). It builds from a GitHub repository, a .zip or a public Docker image, and it runs Node and npm servers. A Next.js app that builds with next build and serves with next start is one of them. These are the steps from repository to a live address.
Before you start
- Your Next.js app is in a GitHub repository, with
buildandstartscripts inpackage.json(next buildandnext start). - You have a DASTER project. DASTER is in testing: new accounts come from the waitlist.
- Your organization's wallet has money in it. Before a deploy starts, DASTER checks that the wallet can pay the next hour of everything you run on Hosting.
Connect GitHub
Open Hosting › Build & deploy settings and choose Connect GitHub. DASTER's GitHub App reads your repositories' contents and metadata, nothing else, and receives push and branch-delete events.
Pick the repository
In Hosting, choose Deploy an app. Pick Web service and a size, then search for your repository under Source and pick it and its branch. If the app lives in a subfolder, set the root directory.
DASTER inspects the selected commit and fills in what it detected. It runs no command at this point.
Review the build settings
Check the install, build and start commands. For a typical Next.js app they are
npm install,npm run buildandnpm start.Set the port to the one your app listens on:
next startuses port 3000 unless you set-porPORT. Set a health check path that answers quickly, such as/or a small API route.Add variables
Add the app's variables for Development. A service can have up to 64 of them, and the values are encrypted at rest.
One thing to know for Next.js: variables are not passed to build commands. Values that
next buildwrites into the browser bundle, such asNEXT_PUBLIC_*variables, are not available while it builds. Keep server-side settings as variables and read them at runtime.Warning: Log lines are redacted, but only values of 8 characters or more are searched for. Keep secrets at least 8 characters long.
Deploy
Choose Review, then Deploy to Development, and follow the build to LIVE. The live card shows the address,
https://<app id>.apps.daster.io.Deploy on every push is on for the new service, so the next push to its branch deploys again. Turn on Preview deployments in Build & deploy settings to get a preview for pushes to other branches.
Sizes and scaling
| Size | One instance | Instances |
|---|---|---|
| Starter | 0.5 vCPU · 256 MB | 1–2 |
| Standard | 1 vCPU · 1 GB | 1–2 |
If your app runs out of memory on Starter, choose Standard. You change the size or the number of instances on the service's Scaling tab, and the change applies with the next deployment. Prices are not final; the Dashboard shows the current ones.
With Autoscale, a web service adds and removes instances with its traffic, between a minimum and a maximum (up to 2 today). A minimum of 0 lets it stop when nobody visits; the next visit then waits a few seconds while an instance starts.
Promote to Production
Owners and admins can use Build & deploy settings › Promote to Production. It runs the exact image of your live Development deployment in Production, without building it again. Production keeps its own variables, and Roll back Production returns it to its previous release.
Use your own domain
Connect a domain you already own under Domains. DASTER shows the DNS records to add and sets up a free Let's Encrypt certificate. See Connect a domain.
The steps above are in the docs too: Deploy from GitHub and Sizes and scaling.
Questions about deploying Next.js on DASTER
Which scripts does my Next.js app need?
A build script that runs next build and a start script that runs next start. DASTER then fills in npm install, npm run build and npm start for you to review.
Which port do I set?
The port your app listens on. next start uses 3000 unless you pass -p or set PORT.
Why are my NEXT_PUBLIC_ variables empty after the build?
Variables are not passed to build commands, and next build writes NEXT_PUBLIC_* values into the browser bundle while it builds. Keep settings as variables and read them on the server at runtime.
How do I ship a new version?
Push to the service's branch. Deploy on every push is on for a service created from GitHub, so each push deploys again. Redeploy builds the branch again by hand.
Can I go back to an earlier version?
Yes. Roll back reuses the image of an earlier deployment and needs a sign-in within the last 10 minutes. In Production, Roll back Production returns it to its previous release.