question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server Side Rendering

See original GitHub issue

Thought 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:closed
  • Created 7 years ago
  • Reactions:25
  • Comments:37 (22 by maintainers)

github_iconTop GitHub Comments

9reactions
diegohazcommented, Nov 18, 2016

Now this repo is working with styled-components, injectGlobal, SSR and everything: https://github.com/diegohaz/arc/tree/fullstack

@thisguychris

8reactions
diegohazcommented, Oct 24, 2016

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. 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found