2
import { useEffect } from "react";
import type { AppProps } from "next/app";
import Script from "next/script";
import { SWRConfig } from "swr";
import { useRouter } from "next/router"
import { AppContext } from "@context/index";
import { NextIntlProvider } from 'next-intl'

function MyApp({ Component, pageProps }: AppProps) {

<SWRConfig
      value={{
        onErrorRetry: (error: any) => {
          // Never retry on 401.
          if (error.status === 401) return;
        },
        errorRetryCount: 2,
      }}
    >
    <>
      <NextIntlProvider messages={pageProps.messages}>
        <AppContext>
          <div>
          
            <Component {...pageProps} />
        
          </div>
        </AppContext>
        </NextIntlProvider>
      
      </>
    </SWRConfig>
 );
}

export default MyApp;

I am getting code: 'MISSING_MESSAGE', originalMessage: 'No messages were configured on the provider.' error even after following documentation of Next-intl it says message is not configured. I have configured that massage in the _app.tsx file page folder. please guide me to solve this issue.

Samruddh Shah
  • 41
  • 2
  • 5

2 Answers2

5

You have then to configure it in the getStaticProps of the page file: You can refer from this link!

gildniy
  • 3,528
  • 1
  • 33
  • 23
2

If anybody else has this problem and nothing works, in my case I was rendering a navbar containing translated messages from _app.tsx, which Next.js renders into the default (implicit) 404 and 500 error handlers, and the error is thrown from there. The solution is explicitly making those custom error pages and loading the translations from their getStaticProps.

999PingGG
  • 54
  • 1
  • 5