i18next / next-i18next

The easiest way to translate your NextJs apps.
https://next.i18next.com
MIT License
5.57k stars 762 forks source link

`Error: No router instance found.` while publishing to Vercel. App works normally in local `yarn dev` #2191

Closed seg-leonelsanches closed 1 year ago

seg-leonelsanches commented 1 year ago

🐛 Bug Report

Error occurred prerendering page "/en-US/account/edit". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No router instance found. you should only use "next/router" inside the client side of your app. https://nextjs.org/docs/messages/no-router-instance

This happens for each locale I implemented (in this project, en-US and pt-BR).

To Reproduce

I implemented in every single page the following:

export async function getStaticProps({ locale }: { locale: any }) {
  return {
    props: {
      ...(await serverSideTranslations(locale, ["common", "footer"])),
      // Will be passed to the page component as props
    },
  };
}

Expected behavior

To publish normally. It works normally for localhost:3000:

Your Environment

adrai commented 1 year ago

have you checked other issues? https://github.com/vercel/next.js/issues/6713

You missed an useEffect in: https://github.com/seg-leonelsanches/leos-guitar-shop-nextjs/blob/main/pages/account/edit.tsx

image
adrai commented 1 year ago

btw: you can see that error also if you run yarn build... there is no need to deploy it to vercel to see the error

seg-leonelsanches commented 1 year ago

have you checked other issues? vercel/next.js#6713

You missed an useEffect in: https://github.com/seg-leonelsanches/leos-guitar-shop-nextjs/blob/main/pages/account/edit.tsx

image

Believe me or not, I did. Github search didn't help.

This solved my issue. Thank you!