mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Render DivJson on the server (SSR) and then hydrate it on the client
Install the packages first:
npm ci
Run sample
npm start
Steps for the SSR
On the server side, use the @divkitframework/divkit/server module:
const html = render({
id: 'test',
json
});
Then respond with this html.
To hydrate with html on the client, use the similar way as in the other samples with 2 changes:
- Use
client-hydratablemodule instead ofclient - Additionally pass
hydrate: trueoption
The json should be the same between the client and the server.
Ya.Divkit.render({
id: 'test',
target: element,
hydrate: true,
json
});