0

I'm using Next.js and with the following config.

module.exports = {
  debug: true,
  backend: {
    backends: [HttpBackend],
    backendOptions: [
      // { expirationTime: 60 * 60 * 1000 },
      {
        loadPath: `${url}/locales/{{lng}}/{{ns}}.json`,
        crossDomain: true,
        requestOptions: {
          mode: 'no-cors',
          cache: 'no-store',
        },
        expirationTime: 60 * 1000,
      },
    ],
  },

  serializeConfig: false,
  use: [ChainedBackend],
  i18n: {
    defaultNS: 'common',
    defaultLocale: 'en',
    locales: ['en'],
    ns: ['common'],
  },
};

Whenever I push update to the api. It should reflect those changes in Nextjs. Right now I need to restart server everytime I update the namespace config

Swapnil Soni
  • 965
  • 1
  • 10
  • 26

2 Answers2

3

Try to set reloadOnPrerender to true: https://github.com/i18next/next-i18next/blob/a2308cf194218f572745322186ddfd6eb541f5ec/examples/simple/next-i18next.config.js#L7

You can also try to set the revalidate option in getStaticProps https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration

adrai
  • 2,495
  • 1
  • 15
  • 18
0

You could use i18next.init() and pass in the config inside your app.jsx or _app.jsx it should work as you expect it to.

Sync271
  • 33
  • 1
  • 6