what is the proper way to enable SSG and ISR?
Unanswered
Siberian Husky posted this in #help-forum
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
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
@Siberian Husky 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
it's impossible ([read here](https://discord.com/channels/752553802359505017/1484525271393632296/1484525271393632296)). What you can do is to use cacheComponents and then revalidate a specific tag. Like that you force the ISR to regenerate and like that you got the new version up and running
@B33fb0n3 it's impossible ([read here](https://discord.com/channels/752553802359505017/1484525271393632296/1484525271393632296)). What you can do is to use cacheComponents and then revalidate a specific tag. Like that you force the ISR to regenerate and like that you got the new version up and running
I dont see he is using search params seem to be using params.
@Siberian Husky 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
that should be cacheable i dont see any reason to that be dynamic have you some dynamic source in some layout like making auth on layout or something like that?
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.
@B33fb0n3 it's impossible ([read here](https://discord.com/channels/752553802359505017/1484525271393632296/1484525271393632296)). What you can do is to use cacheComponents and then revalidate a specific tag. Like that you force the ISR to regenerate and like that you got the new version up and running
Siberian HuskyOP
thank you for participating but it's not about the params.
@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
What happened I did not added the
about your experience in Next-intl, I'm curious, how did you produced SSG routes without using
the following link is about why we use
https://next-intl.dev/docs/routing/setup#add-setrequestlocale-to-all-relevant-layouts-and-pages
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.