Description
Documentation Issue about the static page
I'm trying to use export: "output"
to generate static pages with Payload, but I couldn't find clear documentation on how to structure.
NOTE: I'm using this website template
I'm especially unsure about how to separate the build between the frontend and the payload.
To generate static, I think to run npm run build:static
only static page without admin.
if (process.env.BUILD_MODE === 'static') {
nextConfig.distDir = 'dist'
nextConfig.output = 'export'
nextConfig.redirects = undefined
// Ignore during build
nextConfig.experimental = {
...nextConfig.experimental,
serverExternalPackages: ['payload', 'mongodb', '@payloadcms/db-mongodb'],
}
}
const finalConfig = process.env.BUILD_MODE === 'static' ? nextConfig : withPayload(nextConfig)
export default finalConfig
I don't know the best way to approach it.
I've also seen a few community threads where others have faced similar difficulties, so this might be a good opportunity to clarify this in the official documents.
Why?
The main reason for going static is cost efficiency — we want to run everything in a fully static environment (e.g. fully cached via CloudFlare or running on AWS Amplify, S3, etc.) without needing a running "server".