i18nexus / next-i18n-router

Next.js App Router internationalized routing and locale detection.
MIT License
260 stars 18 forks source link

Issue with Pages Transitioning from Static to SSG after Implementing i18next Package #91

Closed Sathyaraj-dev closed 3 months ago

Sathyaraj-dev commented 3 months ago

Before implementing the i18next, react-i18next, i18next-resources-to-backend, and next-i18n-router packages, all my pages were being prerendered as static content. However, after incorporating these packages, all the pages are now rendered as SSG (using getStaticProps), and they are not being cached.

Is there a solution to maintain static rendering and caching while using these packages? Any advice or guidance would be greatly appreciated.

Thanks,

i18nexus commented 3 months ago

If you are trying to use static export, it will not work with this library. Since this library is dependent on middleware, static export is not supported. You can read more here: https://nextjs.org/docs/app/building-your-application/deploying/static-exports

i18nexus commented 3 months ago

For best performance using next-i18n-router, it is recommended to use generateStaticParams with your supported locales as seen in our example: https://github.com/i18nexus/next-i18n-router/blob/main/examples/i18next-example/app/%5Blocale%5D/layout.tsx#L15

Sathyaraj-dev commented 3 months ago

I am already using generateStaticParams, but all the pages are still coming through as dynamic. Please see the screenshot below for reference.

image

Could you please check if there are any issues in the code? Any help would be greatly appreciated.

Thanks.

i18nexus commented 3 months ago

Can you try running our example project and seeing if it works for you as expected? https://github.com/i18nexus/next-i18n-router/tree/main/examples/i18next-example

Sathyaraj-dev commented 3 months ago

Thanks for the clarification. It's working fine now. The issue was on my side due to adding a timestamp in the fetch API. I appreciate the quick response!

Thanks again.