Not found didn’t work NextJS v14.2.x

I have a problem with Next.JS’s not-found.tsx (using /app)

Here’s the error:

Error: Usage of next-intl APIs in Server Components currently opts into dynamic rendering. 
This limitation will eventually be lifted, but as a stopgap solution, you can use the 
`unstable_setRequestLocale` API to enable static rendering

Route /_not-found couldn't be rendered statically because it used `headers

Error occurred prerendering page "/_not-found"

my not-found.tsx

import React from "react";
import {unstable_setRequestLocale} from "next-intl/server";
import {NextIntlClientProvider, useLocale} from "next-intl";

export default function NotFound() {
    const locale = useLocale();
    unstable_setRequestLocale(locale)
    return (
        <NextIntlClientProvider locale={locale}>
            <span>Not found</span>
        </NextIntlClientProvider>
    );
};

path to file: src/app/not-found.tsx

I also use [locale]/ folder, for next-intl

You should also know that in “npm run dev”, it works fine, but as soon as I put it into production (via vercel), I get the error above.

Please, help me

Hi @svetlanazinovkina. It looks like this error is related to the next-intl package. I don’t know much about that one, but the maintainer of the amannn/next-intl repo may know how to fix it. You can also use vercel build or vercel build --debug on your local repo to get more details about the error.

Alternatively, the internationalization features included in Next.js may suit your needs.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.