-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Docs]: useTranslations() vs getTranslations() for server contexts? #734
Comments
… Server Components by making sure we only suspend when i18n config is initially loaded and never for subsequent calls (#741) Fixes #734 by making sure we suspend only once when loading configuration. See also https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md#resuming-a-suspended-component-by-replaying-its-execution
Thank you so much for the kind words @j0nas, I really appreciate it! ❤️ Also, great question! While replying here I actually noticed that there was an optimization missing that resulted in hooks unnecessarily suspending. I've fixed this in #741 and now the answer really is that the two can be used interchangeably :). I've also added some details to the "Should I use async or non-async functions for my components?" expandable section in the Non-async components docs. Have a look and let me know if this sufficiently answers your questions!
Yep, currently waiting for lokalise/i18n-ally#1048 to get merged 🙏 |
That response time is incredible, @amannn! 🤩
Thank you for clarifying. The docs added in #741 help in this regard, but for someone looking for a black-and-white answer, reading "it's essentially the same" hits the spot. 🎯 (Maaaaybe worth adding that one sentence to the docs as well, to be super explicit? 😄) So I'll stick to Again, I appreciate this all a lot, thank you! |
… Server Components by making sure we only suspend when i18n config is initially loaded and never for subsequent calls (amannn#741) Fixes amannn#734 by making sure we suspend only once when loading configuration. See also https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md#resuming-a-suspended-component-by-replaying-its-execution
Link to page
https://next-intl-docs.vercel.app/docs/environments/server-client-components#async-components
Describe the problem
Hi @amannn! First of all, thank you so much for a great library! I was following #149 for a while and it was so cool to see you be so responsive and helpful with everyone. When 3.0 dropped, I started integrating
next-intl
into the app I'm building and it's been working like a charm so far! 😍 All this to say, thank you so much for all your hard work, it does not go by unnoticed!Now, my question pertains to the difference between
next-intl/server
'sgetTranslations
vs.next-intl
'suseTranslations
in a server context. I've generally been usingasync
components andawait getTranslations
, but noticed that I'd accidentally useduseTranslations
in some components and couldn't tell any difference in terms of outcome. The docs also start of by showing an example using theuseTranslations
hook, but then also show agetTranslations
-based example with an async component. There is also a section that helpfully explains the difference, so maybe it's just me being slow and wanting to be sure: can I useuseTranslations
with no performance penalty in server contexts, or should I prefer toawait getTranslations
withasync
components in such cases? Is there a difference?I would prefer to
useTranslations
because then I wouldn't have to convert all my components to async components, and also becausegetTranslations
doesn't get picked up by the i18n ally plugin (thank you for mentioning that plugin in the docs!), but ifawait getTranslations
is more performant somehow then that'll obviously be the way to go for me.The text was updated successfully, but these errors were encountered: