Comments (4)
Does it helps? https://github.com/nanostores/i18n#server-side-rendering
from i18n.
in this example let locale, i18n
will shared for all users on each request.
How can i hydrate locales to store and cleanup on server?
So, in Next.js i need serialised data to gssp props
import { locale } from 'nanostores'
let locale, i18n
if (isServer) {
locale = atom(db.getUser(userId).locale || parseHttpLocaleHeader())
i18n = createI18n(locale, {
async get (code) {
return JSON.parse(await readFile(`public/translations/${code}.json`))
}
})
} else {
…
}
export { locale, i18n }
from i18n.
in this example let locale, i18n will shared for all users on each request.
You need to use your framework’s APIs for this. You can avoid using a separated file for every store and initialize all stores together in some functions like buildContext()
. Or you can export store builder from every file.
So, in Next.js i need serialised data to gssp props
Sorry, I do not use Next.js to suggest exact solution.
If you need some specific API, ask for it.
from i18n.
I am closing this issue. We have a similar “What is the best SSR integration” discussion in main Nano Stores repository.
But without an API suggestions from Next.js users I can’t help.
from i18n.
Related Issues (13)
- Translation preprocessor
- number, time and count functions type mismatch HOT 6
- Add HMR support HOT 1
- is there a nice way to use nanostores/i18n outside of react / react-hooks? HOT 27
- does nanostores/i18n process process lists in international way? HOT 1
- runtime error when NODE_ENV === 'production', HOT 6
- Prevent `baseTranslation` from flashing HOT 9
- Error while using useStore HOT 4
- Usage in sandboxes HOT 2
- Nesting of translations HOT 3
- Add partial translation loading HOT 2
- Clears data from local storage after page refresh HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n.