i18nexus / next-i18n-router

Next.js App Router internationalized routing and locale detection.
MIT License
260 stars 18 forks source link

question: how to pass the t fucntion between server component #61

Closed zakidze closed 8 months ago

zakidze commented 8 months ago

hello

how to pass the t functions to to deeply nested server component without prop drilling is there a way????

i mean initlise it once in the page then use it deeply in server component nested?

i18nexus commented 8 months ago

You can just use the initTranslations function in our examples in any server component to get access to the t function. The problem is that to run initTranslations you have to have the current locale from your params. You would have to prop-drill the locale param in this case.

Alternatively, you can create a store to share the locale param throughout server components without prop-drilling as discussed here.

zakidze commented 8 months ago

thank you for your anwser feel free to close the issue if not needed anymoer