Next.js hosting with Postgres included.
Add a Dockerfile, run one command, and your Next.js app is live in its own container with a Postgres database already connected.
1. Tell Next.js to build a standalone server
A standalone build puts everything the server needs in one folder, which keeps the image small.
import type { NextConfig } from "next";
const nextConfig: NextConfig = { output: "standalone" };
export default nextConfig;2. Add a Dockerfile at the project root
A project with a Dockerfile is built with Docker. Without one, a Node app is installed and started with npm start and no build step, which isn't enough for Next.js. The port you EXPOSE is the one visitors are sent to.
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
COPY --from=build /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]3. Read the database from DATABASE_URL
Every server app gets its own Postgres database, and DATABASE_URL is set in the container when it runs. Use it with any client: pg, Drizzle or Prisma. It isn't set while the image builds, so pages that query the database must render at request time, and migrations should run when the container starts.
import { Pool } from "pg";
export const db = new Pool({ connectionString: process.env.DATABASE_URL });4. Deploy
Run this in the project folder. The first run opens your browser to connect your account. It uploads what git tracks (never node_modules or .next), saves the variables in a root .env as the app's secrets, builds the image and prints the live address. Run it again to update the same app.
npx @kickstartmvp/deployWhat the Free plan includes, and what it doesn't
- The Free plan is $0 and runs 2 apps. Each has its own Postgres database.
- A Free app with no visits for 30 minutes sleeps and wakes on the next visit, so the first request after a quiet spell is slower. Plus ($8 a month) keeps apps always on.
- Custom domains start on Plus. On Free the app lives on a kickstartmvp.com address with a small badge.
- An upload on Free can be up to 25 MB, which is your source without node_modules.
- The database accepts connections only from your app, not from your laptop.
Fair questions.
Yes. Without one, a Node app is started with npm start and nothing runs next build first. The Dockerfile above builds the app and starts the standalone server.
Let’s make your app real.
Start with an idea. We’ll take care of the build and hosting.