martinkr/next-export-i18n

App router migration - Error: NextRouter was not mounted

jimmyrleung opened this issue · 3 comments

Hey,

We are currently migrating our Next.js application to App Router, and we are seeing the issue below.

This is probably happening because the useTranslation and useSelectedLanguage hooks use useRouter from next/router, which is not supported by the app router as mentioned here

image

Would you have any plans to migrate to using the new navigation hooks from next?

Also, I can see that the router is even not used in the useTranslation hook, it could be removed, but the useSelectedLanguage would require an actual migration

https://github.com/martinkr/next-export-i18n/blob/main/module/src/hooks/use-translation.tsx
https://github.com/martinkr/next-export-i18n/blob/main/module/src/hooks/use-selected-language.tsx

Thanks,
Jimmy.

@martinkr just wanted to thank you for releasing the temporary beta version for v3, we updated it this past sprint and it worked like a charm, we'll now work to update to the stable v3, really appreciate it!

Hi @jimmyrleung,

Thank you for your great contribution!
Glad to hear that the beta worked for you. If you have any issues with v3 or additional feature ideas, let me know.

Cheers!