How can I use Next.js internationalization with client components?
Answered
Transvaal lion posted this in #help-forum
Transvaal lionOP
Hi all, I’ve been looking into Next.js (App Router) internationalization https://nextjs.org/docs/app/building-your-application/routing/internationalization internationalization, and it's great that it has built-in support. However, does this mean it only works with server-side components? I couldn’t find anything in the documentation about client components.
Answered by B33fb0n3
you can get the translations serverside and pass them down to the client. Either fetch them over and over again and pass them where you need them or create a DictonaryProvider (clientside context) that receives the dictonary and provides it to all nested client components
4 Replies
@Transvaal lion Hi all, I’ve been looking into Next.js (App Router) internationalization https://nextjs.org/docs/app/building-your-application/routing/internationalization internationalization, and it's great that it has built-in support. However, does this mean it only works with server-side components? I couldn’t find anything in the documentation about client components.
you can get the translations serverside and pass them down to the client. Either fetch them over and over again and pass them where you need them or create a DictonaryProvider (clientside context) that receives the dictonary and provides it to all nested client components
Answer
Transvaal lionOP
Yeah, I was thinking of implementing it like that, but I thought maybe Next.js has something built in
@B33fb0n3 Thank you
happy to help