Home > Net >  next-i18next: update changes without restarting server on dev and production both
next-i18next: update changes without restarting server on dev and production both

Time:07-14

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

CodePudding user response:

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

CodePudding user response:

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.

  • Related