React Loadable SSR Add-on (npm package `react-loadable-ssr-addon-v5-slorber`, version 1.0.3) is a specialized server-side rendering utility designed to complement `React Loadable` for managing dynamically loaded JavaScript and CSS assets. It integrates with Webpack via a plugin that generates an `assets-manifest.json` file, detailing all bundled chunks and their dependencies. On the server, it consumes this manifest along with module IDs captured by `Loadable.Capture` to correctly inject the required `<link>` and `<script>` tags into the HTML response. A key differentiator is its optional support for Subresource Integrity (SRI), enhancing security by adding cryptographic hashes to asset links. While the specific package name includes 'v5-slorber', its peer dependencies indicate broad compatibility with `react-loadable` and `webpack` v4/v5, making it a robust solution for ensuring all necessary assets, including code-split chunks, are present during SSR without client-side fetching delays. There is no explicit release cadence stated, but the 1.x.x version implies a stable API.
npm install react-loadable-ssr-addon-v5-slorberVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core usage of `react-loadable-ssr-addon` by configuring its Webpack plugin to generate an `assets-manifest.json` file. It then utilizes the `getBundles` function on the server to dynamically inject the correct CSS and JavaScript bundles, including code-split chunks and Subresource Integrity (SRI) hashes, into the server-rendered HTML response, ensuring all required assets are loaded for a complete SSR experience.
Ensure the package is listed under `dependencies` in your `package.json` file, and install it using `npm install react-loadable-ssr-addon` or `yarn add react-loadable-ssr-addon`.
Experiment with the order of concatenating `modulesToBeLoaded`. If `[...manifest.entrypoints, ...Array.from(modules)]` causes issues, try `[...Array.from(modules), ...manifest.entrypoints]`. Refer to issue #6 on the GitHub repository for more context.
Set the `integrity: true` option in the `ReactLoadableSSRAddon` Webpack plugin configuration, e.g., `new ReactLoadableSSRAddon({ filename: 'assets-manifest.json', integrity: true })`.Run `npm install react-loadable-ssr-addon` or `yarn add react-loadable-ssr-addon`. Verify that the import or require path matches the package name.
Ensure the `ReactLoadableSSRAddon` Webpack plugin is correctly configured and runs during your build. Check the `filename` option in the plugin to ensure the manifest is written to the expected location, and verify the `import manifest from './path/to/assets-manifest.json'` statement on your server points to the correct file.
For server-side usage of `getBundles`, use ES Modules `import` syntax: `import { getBundles } from 'react-loadable-ssr-addon';`. Ensure your Node.js environment or build setup supports ES Modules.