Description
isomorphic-style-loader is a CSS style loader for Webpack, built for isomorphic or universal web apps that render on both the server and the client. It works in a similar way to style-loader, but it is designed for critical-path CSS rendering. It adds two helper methods to the styles object: one injects CSS into the DOM, and one returns a CSS string to put in the server-rendered HTML. On the server, only the CSS that the rendered page actually uses is included in the HTML, which helps avoid a flash of unstyled content. CSS of components that are no longer mounted is removed from the DOM. On the client, the bundle hydrates the markup to make it interactive. Hooks are supported, so useStyles can be used in function components as well as withStyles, provided insertCss is passed through a StyleContext provider at the top of the tree. Requirements are Webpack 5, React 16.8 or newer, and css-loader configured with esModule set to false, because the loader reads class names from exports.locals. Version 6 changed behavior: static properties of the wrapped component are no longer hoisted onto the component that withStyles returns, and prop-types validation has been removed. The project is MIT licensed and is aimed at developers building server-rendered React apps.…
Highlights
- Critical-path CSS rendering for server-rendered React
- Helpers for injecting CSS and returning a CSS string
- Removes CSS of unmounted components
- Supports withStyles and useStyles hooks
- Works with Webpack 5 and React 16.8 or newer
Ratings & Reviews
No ratings yet
Be the first to rate Isomorphic Style Loader.
People also visit
Isomorphic Style Loader FAQ
What does this loader do?
It loads CSS for Webpack in isomorphic React apps, so only the critical CSS for the rendered page goes into the server HTML.
What do I need to use it?
Webpack 5, React 16.8 or newer, and css-loader with esModule set to false.
What changed in version 6?
Static properties of the wrapped component are no longer hoisted onto the component from withStyles, and prop-types validation has been removed.
Can I use hooks?
Yes. useStyles works in function components, and you still need to pass insertCss through a StyleContext provider at the top of the tree.
Can the getCss option use closures?
No. The README says the getCss option is serialized into the generated module, so it must be a self-contained function.
What license applies?
MIT, according to the README.
What are the best Isomorphic Style Loader alternatives?
Popular alternatives to Isomorphic Style Loader include React Styleguidist, Styled components and React Spinners CSS. See all Isomorphic Style Loader alternatives














