How we do streaming server-side rendering and caching for SpectrumFebruary 7, 2018 at 4:10pm
Just published on the Zeit blog: https://zeit.co/blog/streaming-server-rendering-at-spectrum
Any questions about streaming SSR?
February 7, 2018 at 4:34pm
My experience has been that streaming works well when styles have been extracted as part of the build process.
But for CSS-in-JS you need to get the full response to send the styles first, otherwise there's a FOUC.
There are "hacks" to get streaming working correctly with css-in-js. It requires interpolating style tags with the html being streamed as chunks are generated by react. see https://github.com/threepointone/glamor-stream
styled-components does exactly that @tk, we have a sheet.interleaveWithNodeStream API which interleaves style tags with the HTML as it gets along
And no, client-side-only rendering is not enough to get indexed on search engines haha
@mxstbr great post! I have tried the interleaveWithNodeStream function. I have got the SSR working however, some of the styles were missing on the part of the UI that was not server-side rendered. I don't know if I am missing a piece or if it's a known problem.
Before you even import any
February 8, 2018 at 3:34am