Static site generation
Unanswered
Al Imam posted this in #help-forum
Al ImamOP
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
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
Al ImamOP
i want middleware to work if any one type wrong url i want to redirect in this case that will not work
Al ImamOP
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
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
@Al Imam 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
Thing is, they should automatically be statically generated by default unless you use a dynamic function in them(or in its layout).
You can try building and checking to see if they are statically generated or not, using the entire list it provides of all dynamic and static pages
You can try building and checking to see if they are statically generated or not, using the entire list it provides of all dynamic and static pages
If you are using dynamic route then you can do this:
https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#generating-static-params
https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#generating-static-params
Another solution which you shouldn't need(read above) is exporting dynamic variable with
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
force-statichttps://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
Al ImamOP
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
Al ImamOP
issue is closed in my case there is no way i guess