@filbert-js/server-stylesheet

A StyleSheet for server-side rendering

Install

yarn add @filbert-js/server-stylesheet

Usage

1import { renderToString } from 'react-dom/server';
2import { createStylesheet } from '@filbert-js/server-stylesheet';
3import App from './App';
4
5const sheet = createStylesheet();
6const app = renderToString(sheet.collectStyles(<App />));
7const styleHTML = sheet.getStyles();
8// Or
9// const styleTags = sheet.getReactElements(); // give React elements
10
11const html = `
12<html>
13 <head>${styleHTML}</head>
14 <body>
15 <div id="app">${app}</div>
16 </body>
17</html>
18`;

More documentation is available at https://filbert-js.vercel.app.