Next.js Discord

Discord Forum

what is the proper way to enable SSG and ISR?

Unanswered
Siberian Husky posted this in #help-forum
Open in Discord
Siberian HuskyOP
hi
I have s problem with SSG that does not works with specific routes.

In this example I have the blog-post route, it must generates SSG at build time, this page have next-intl to localize and get api requests.

you can see the blog-posts/[slug]/page.tsx on the following link:
https://github.com/sfwnisme/frontend-real-estate/blob/feat/site-info/app/%5Blocale%5D/(client)/(pages)/blog-posts/%5Bslug%5D/page.tsx

the purpoes of this page:
- generated as SSG without any issue
- ⁠enables the ISR to refresh the data if changes happened on the page


the problem:
I have to use ‘export const dynamic = “force-static”’ and ‘export const invalidate = 60’
, so I can enable the SSG generating.


Conclusion:
I need to know the right way to do SSG. and ISR and I think I am doing a wrong thing with the requests functions or the next-intl

9 Replies

@Nuitari also that line is not needed at all [] is an array of length 0 so your code is kinda if x=a return a. I had used next-intl and it always generate StaticParams without problems.
Siberian HuskyOP
It sounds more exciting, especially you said you worked with Next-intl without SSG issue.
Current Status:
I solved the issue, it was about the setRequestLocale() Next-intl's function, that overrides the dynamic components to enable SSG.
What happened I did not added the setRequestLocale() in the layout.tsx of the desired route, so, the issue happened and I must use force-static page level.

about your experience in Next-intl, I'm curious, how did you produced SSG routes without using setRequestLocale(), me I have to add it so I can work for SSG.

the following link is about why we use setRequestLocale() from Next-intl's Documentation:
https://next-intl.dev/docs/routing/setup#add-setrequestlocale-to-all-relevant-layouts-and-pages
oh you use params in layout i never found the need for use in layout.
@Nuitari oh you use params in layout i never found the need for use in layout.
Siberian HuskyOP
is the issue because using the params in layout?
if you use generateStatic params and you dont have any dynamic data source SSG (or i should say ISR) should be fine.