Next.js Discord

Discord Forum

Static website with (prebuilt?) localization

Unanswered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP
Hi, I'm migrating one of my projects from Gatsby to Next14 and I got stuck.

What I'm trying to achieve:
1. Static website (I don't need to manipulate the requests/responses, do any redirects etc)
2. Locale is known when building the app, so i think it should be possible to include the translation messages in the bundle. I use react-intl, so I define the messages with <FormattedMessage ... /> and propagate the translations with <IntlProvider ... />


Since react-intl's IntlProvider uses createContext to pass the messages to FormattedMessage components does it mean, that a localized component needs to have the "use client" directive and won't get rendered by the server (probably leading to bad SEO etc.?) or I understood it wrong?


So my question basically is:
- How to use react-intl with the server and client components?
- Is react-intl even a good choice to be used with client/server components? It feels like the translations should be done for each component rather than for whole app / page etc?


Thank you.

0 Replies