Paraglide in Server Components #1776
-
ProblemCan we use Paraglide in Server Components? I know paraglide runs on client but would there be a way to feed the data? I am using Next.js 14 App Dir. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi @anaclumos, I moved this to Q&A. Yes. Our initial tests with the NextJS app dir and RSC worked fine, see https://github.com/inlang/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-next/example. The reasoning is simple. Paraglide compiles plain JS functions. RSC can render JS functions. @LorisSigrist can share more about an official NextJS adapter. |
Beta Was this translation helpful? Give feedback.
-
Yes! You can use ParaglideJS with Server Components. Here is an example project on how to do that. Soon there will be a written Guide on how to do this too. We will also encapsulate all the reuseable parts into a package, so that you won't have to do the setup on every project. Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
@LorisSigrist Hey, I've checked your adapter for next.js App directory. An alternative approach I'm implementing now, is to receive the "lang" param (incase opted for dynamic [lang] routes) in a page/layout and provide it to the m-function using prop drilling ex. |
Beta Was this translation helpful? Give feedback.
Yes! You can use ParaglideJS with Server Components.
You can even mix Server & Client components and it still works! You just need to make sure that the language get's set on both the server and the client.
Here is an example project on how to do that. Soon there will be a written Guide on how to do this too. We will also encapsulate all the reuseable parts into a package, so that you won't have to do the setup on every project.
Hope that helps!