Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Building without a DB connection

One of the most common problems when building a site for production, especially with Docker - is the DB connection requirement.

The important note is that Payload by itself does not have this requirement, But Next.js' SSG does if any of your route segments have SSG enabled (which is default, unless you opted out or used a Dynamic API) and use the Payload Local API.

Solutions:

Using the experimental-build-mode Next.js build flag

You can run Next.js build using the pnpx next build --experimental-build-mode compile command to only compile the code without static generation, which does not require a DB connection. In that case, your pages will be rendered dynamically, but after that, you can still generate static pages using the pnpx next build --experimental-build-mode generate command when you have a DB connection.

Next.js documentation

Opting-out of SSG

You can opt out of SSG by adding this all the route segment files:

1
export const dynamic = 'force-dynamic'

Note that it will disable static optimization and your site will be slower. More on Next.js documentation

Next

Production Deployment