Skip to content

Instantly share code, notes, and snippets.

Last active December 10, 2018 03:07
What would you like to do?
import { getDataFromTree } from "react-apollo"
app.use((req, res) => {
const client = new ApolloClient(...);
getDataFromTree(App).then(() => {
const content = ReactDOM.renderToString(App);
const initialState = client.extract();
const html = <Html content={content} state={initialState} />;
res.send(`<!doctype html>\n${ReactDOM.renderToStaticMarkup(html)}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment