-
I followed the example here and got Next Intl up and running quite nicely. Today I wanted to install MDX and followed the guide in the Next JS docs as well as the Next Intl docs, but I can only get it working for the home page. The reason, it seems, is that only the home page can be an async component, not so the localized routes. I keep getting the following error when attempting to import a localized mdx file in src/app/[locale]/kudos/page.tsx
My code for src/app/[locale]/kudos/page.tsx is as follows
When I remove the async keyword and the dynamic import in the try/catch everything works. As soon as I put back the async keyword, I again get the internal error. Are default async page components supposed to work? I must be doing something wrong, but I have no idea what. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Ah, after trying different things for several hours, right after posting the question I believe I've figured it out ... |
Beta Was this translation helpful? Give feedback.
-
Looking at your code sample, the issue seems to be that you're calling the hook The latest version of |
Beta Was this translation helpful? Give feedback.
-
Exactly, I was going to post an answer today with the solution. Thanks! |
Beta Was this translation helpful? Give feedback.
Looking at your code sample, the issue seems to be that you're calling the hook
useTranslations
in an async component. Hooks are generally not supported in async components. You can resolve this, by switching toawait getTranslations
.The latest version of
eslint-plugin-react-hooks
also includes a check to avoid this error.