-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Support for client side rendering (v8) #993
Comments
+1 on this |
Not sure I follow – even if you want to do client side rendering, why not send down the translations hypothetically necessary with the HTML document, as opposed to a separate network request? |
@isaachinman the point is, we totally did not use But now in the |
@hgbao Then, I think a solution would be dependent on the global singleton that we want to release for #983. Flow would go like such: First, add i18next-http-backend via Then, in your code, you can do: import { i18n } from 'next-i18next'
i18n.reloadResources(locale, namespace) Let me know if that makes sense. As I say, this depends upon the global i18n client being exposed, which is still a work in progress. |
Hi Isaac, thanks for your work on this, it's coming just in time for us :) Can you please add an example to the readme/doc on how to implement the global singleton solution? I don't really understand how i18next-http-backend comes into it, or how to configure it for this purpose. |
@nicolasconnault The global singleton is now merged, and you can do: import { i18n } from 'next-i18next'
i18n.reloadResources(locale, namespace) To make this work over http (client side), you'll need to add something like this to your const i18nextHttpBackend = require("i18next-http-backend").default;
module.exports = {
i18n: {
defaultLocale: "en",
locales: ["en", "de"],
},
use: process.browser ? [i18nextHttpBackend] : [],
}; |
@isaachinman thanks for your help Isaac, much appreciated! |
Hi again @isaachinman , we're having some difficulty with this code, as the i18n export from next-i18next is a type, and has no reloadResources function. We can only get reloadResources from import { i18n } from "next-i18next/src/index"; But when we call i18n.reloadResources we get Do we need to configure i18next-http-backend as described here? https://github.com/i18next/i18next-http-backend |
@nicolasconnault The type is defined here. It sounds like the actual |
Hi, Is this feature implemented? I will be very thankful for your reply. |
@adrai thanks for your reply. Can you share an example? I couldn't manage to solve my problem.
|
Thanks, I will check it |
Is your feature request related to a problem? Please describe.
At the moment (on v.8.0.1) it seems like you're forced to use either
getServerSideProps
orgetStaticProps
functions on the page level. However there might be cases where you don't want to use either. One example would be some sort of dashboard where data is changing frequently and it makes no sense to pre-render the page.Describe the solution you'd like
It would be nice if you could just use the
useTranslation
hook without exportinggetServerSideProps
orgetStaticProps
and using serverSideTranslations inside them.Describe alternatives you've considered
Haven't figured out any other methods to get this working than to use either
getServerSideProps
orgetStaticProps
.Additional context
When I'm talking about client side rendering in this feature request I'm referring this:
https://nextjs.org/docs/basic-features/data-fetching#fetching-data-on-the-client-side
The text was updated successfully, but these errors were encountered: