next-intl: I keep getting missing messages errors

Using the latest next 10.x

I have my file setup as:

src
-- messages
-- -- header
-- -- -- en.json

_app has:

MyApp.getInitialProps = async function getInitialProps(context) {
  const { locale } = context.router
  return {
    ...(await NextApp.getInitialProps(context)),
    messages: require(`../messages/header/${locale}.json`),
  }
}

I have checked that it gets locale correctly but console keeps throwing errors:

 code: 'MISSING_MESSAGE',
  originalMessage: 'No messages available at `undefined`.'

Any ideas what I could be missing here?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@Pixelatex Did you solve the issue in the end? I am currently seeing this error when running next build and have no clue where to start debugging …

IntlError: MISSING_MESSAGE: No messages available at `undefined`.

Your example had an infinite loop. In App.getInitialProps you can’t call App.getInitialProps again. I changed it to reference NextApp now.

Seems like what you pass in the _app.getInitialProps doesn’t get passed to the _app pageProps.

Yep, when you return something from App.getInitialProps, it’s available as a regular prop within App (not pageProps).

Here’s a fixed version https://codesandbox.io/s/next-intl-template-fixed-x2lvm

Does that solve your issue?