Server Side Rendering
See original GitHub issueThought I’d open an issue to kick off the discussion. It’s already possible because of the way we build on top of Glamor, but we haven’t exposed it as an API. But basically, if you did this:
import styleSheet from 'styled-components/lib/models/StyleSheet'
/* before each render */
styleSheet.flush()
/* after each render */
styleSheet.rules().map(rule => rule.cssText).join('\n')
Then you should get the chunk of CSS you need for each request. Can someone with a server-rendered setup take a look and confirm this works, and maybe show how they’d be invoking it? I’d be happy enough to export something like:
import { serverStylesheet } from 'styled-components'
/* before each render */
serverStylesheet.reset()
/* after each render */
serverStylesheet.getCSS()
What do people think?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:25
- Comments:37 (22 by maintainers)
Top Results From Across the Web
What is Server-Side Rendering? Definition and FAQs
Server -side rendering (SSR) is an application's ability to convert HTML files on the server into a fully rendered HTML page for the...
Read more >What's Server Side Rendering and do I need it? - Medium
What's Server Side Rendering and do I need it? Introduction of modern JavaScript frameworks / libraries that focus on creating interactive ...
Read more >Client-side vs. server-side rendering: why it's not all black and ...
Server -side rendering is the most common method for displaying information onto the screen. It works by converting HTML files in the server...
Read more >What is server-side rendering? - Educative.io
Server -side rendering (SSR), is the ability of an application to contribute by displaying the web-page on the server instead of rendering it...
Read more >Rendering on the Web
SSR : Server-Side Rendering - rendering a client-side or universal app to HTML on the server. CSR: Client-Side Rendering - rendering an app...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Now this repo is working with
styled-components
,injectGlobal
, SSR and everything: https://github.com/diegohaz/arc/tree/fullstack@thisguychris
Demo: https://arc.diegohaz.com (disable javascript, even the form works). Code: https://github.com/diegohaz/arc/blob/universal-redux/src/server.js#L74
It doesn’t work with
injectGlobal
(I removed).The
serverStylesheet.getCSS()
API would be nice. 👍