Next.js Discord

Discord Forum

When I run npm run build, there is a dynamic file missing in the "out" folder. How to fix?

Answered
Singapura posted this in #help-forum
Open in Discord
SingapuraOP
In my config I have
const nextConfig = {
  output: "export",
which afaik is for static files but in the same project I have a dynamic file which makes an api call that I need to use. How do I get this working? Thank you
Answered by joulev
if you want to have a dynamically rendered page (meaning, it is run every request), it's impossible to have it with static export.
View full answer

9 Replies

SingapuraOP
HELP!
if you want to have a dynamically rendered page (meaning, it is run every request), it's impossible to have it with static export.
Answer
SingapuraOP
So its a contact form, the user puts some data and it gets sent to my email in real time
@Singapura So its a contact form, the user puts some data and it gets sent to my email in real time
this requires server-side processing of the form, which is not possible with static export*

* unless your hosting platform offers something for this, something like [netlify forms](https://www.netlify.com/platform/core/forms/)
Tomistoma
"export": "yarn run build && yarn run export" working always for me
This will generate an out directory for you in you project.

Also u can customize it in next.config.js like :

/* config options here */
const nextConfig = {
output: 'export',
images: {
unoptimized: true,
},
distDir: 'out', // Where to export all pages
trailingSlash: true,
assetPrefix: '.',


// time in seconds of no pages generating during static
// generation before timing out
staticPageGenerationTimeout: 1000,
reactStrictMode: false
}
@Singapura So what does one do in this case? I was trying to host the website on namecheap, using the setup nodejs app option, I followed this: https://nextjs.org/docs/pages/building-your-application/configuring/custom-server but i was having some trouble
im honestly not exactly sure. you can look up how to integrate forms into a static website.

some hosting platforms, especially the cheaper/no-cost ones, only support exclusively static hosting (so a custom server is not possible there). i don't know whether namecheap supports it or not.