done-ssr-middleware is an Express/Connect middleware designed to integrate server-side rendering capabilities into DoneJS applications. The current stable version is 3.0.1, which aligns with the DoneJS 3.0 ecosystem. It provides a straightforward way to add SSR to an existing Node.js server, allowing DoneJS applications to be pre-rendered for faster initial page loads and improved SEO. Key features include configurable SSR options inherited from `done-ssr`, and a live-reload utility to automatically refresh the SSR cache during development. It differentiates itself by tightly integrating with the DoneJS framework's module loading and rendering pipeline, leveraging `done-ssr` for the core rendering logic.
npm install done-ssr-middlewareVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `done-ssr-middleware` into an Express application, configuring it to serve a DoneJS application with server-side rendering and enabling live-reload for development environments. It correctly places the middleware relative to static asset serving and includes basic error handling.
Consult the `done-ssr` v3.0.0 release notes (linked from the `done-ssr-middleware` v3.0.0 announcement) for a comprehensive list of breaking changes and migration steps, and update your DoneJS application and middleware options accordingly.
Ensure `app.use(ssrMiddleware(systemOptions, middlewareOptions))` is called after `app.use(express.static(...))` or specific `app.get(...)` routes, but always before `app.use((err, req, res, next) => { ... })`.Pass `{ strategy: 'incremental' }` as a property within the *second* argument (the `middlewareOptions` object) to the `ssrMiddleware()` factory function, for example: `app.use(ssrMiddleware({ config: '...' }, { strategy: 'incremental' }));`Ensure the `packageName` property is explicitly defined in the first argument (the `systemOptions` object) of the `ssrMiddleware` factory. Example: `ssrMiddleware({ config: ..., packageName: 'your-app-name' }, options);`Ensure your error handling middleware function includes all four arguments, even if `next` is not directly used: `app.use((err, req, res, next) => { /* handle error */ });`