amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.58k stars 236 forks source link

t is not a function #1326

Closed imbhargav5 closed 2 months ago

imbhargav5 commented 2 months ago

Description

I see t is not a function error when I try to use the Link component exported by @/i18n/routing. My understanding is that the Link component is implemented independently in both server and client component environments and should work in both places. However, I am running into this issue in the server environment and the client environment works fine.

image

Verifications

Mandatory reproduction URL

https://github.com/imbhargav5/next-intl-bug-repro

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Start dev server on 3000
  3. Home page will error on the server

Expected behaviour

There should be no t is not a function error in the server side and the Link function should use the current locale from cache and navigate correctly.

amannn commented 2 months ago

Your example is broken because you've specified the wrong path in next.config.mjs. Please make sure to link to your request configuration, not your routing configuration. If you remove the override in the reproduction, then your i18n/request.ts file is picked up correctly.

I've added https://github.com/amannn/next-intl/pull/1327 to introduce error handling for this case, thanks for the report!

imbhargav5 commented 2 months ago

Amazing. Your speed is next level. Thanks for this amazing project good sir!

amannn commented 2 months ago

Awesome, happy to help! 😊