Next.js Discord

Discord Forum

Static site generation

Unanswered
Al Imam posted this in #help-forum
Open in Discord
I have a page not dynamic params page just a page that calls an api and render the data response how ever it is only required in development on production i just want static side and make the page static on build step (on build step call the api and build static site with the data)

13 Replies

The route should be statically generated by default unless you use dynamic function(s).

You can also statically export your site if you want a completely static site. This does come with some repercussions however:
https://nextjs.org/docs/app/building-your-application/deploying/static-exports#unsupported-features
i want middleware to work if any one type wrong url i want to redirect in this case that will not work
for example i have a array [1, 2, 3]
I'm prerendering them as
/[number]/page.tsx this page is statically generated on build time

also i have a side nav where I'm showing the available /[number] pages so user can navigate. form my nav component I'm fetching the [number] array form my server but the thing is my pages are prepared so i know they will never change without new build so it will be helpful for me if i can make nav component prerender (statically generated)

then here's come next point when someone try to access my website index page there is no index page so I'm rewrite the request to send user to one of the [number] page so that's why I want middleware to work, also there is auto url heal feature when someone type one of the [number] page url but not correct url the url direct them to correct page
Another solution which you shouldn't need(read above) is exporting dynamic variable with force-static

https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
not working
it causes infinite loop some how my middleware always get the / index path in throw im requstuing /dua?cat=1 page
dont make any sense but it's happeing
issue is closed in my case there is no way i guess