This package provides an Express middleware designed to facilitate dynamic rendering for web applications by integrating with a Rendertron service. It operates by inspecting incoming HTTP requests' User-Agent headers, and if a known bot or crawler is detected, it proxies the request to a separately deployed Rendertron instance. The Rendertron service, in turn, renders the page using a headless Chrome instance, returning static HTML suitable for search engines and social media bots that may not execute client-side JavaScript. The current stable version of this middleware is 0.1.5, which was last published over 7 years ago. The upstream Rendertron project itself has been officially deprecated since October 2022, with its maintainers stating that dynamic rendering is no longer the recommended approach for SEO. Consequently, this `rendertron-middleware` package is effectively abandoned and no longer maintained.
npm install rendertron-middlewareVerified import paths — ran on the pinned version, not inferred.
Sets up an Express server with `rendertron-middleware` to proxy requests from detected bots to a specified Rendertron service, serving static files for other requests.
Migrate to server-side rendering (SSR), static site generation (SSG), or ensure your client-side rendered application provides robust SEO for modern crawlers without dynamic rendering. Consider alternatives like Next.js, Nuxt.js, or similar frameworks that inherently support SSR/SSG.
Always provide a `proxyUrl` in the `makeMiddleware` configuration object, pointing to your deployed Rendertron service. Example: `proxyUrl: 'https://my-rendertron-instance.appspot.com/render'`.
Ensure your Rendertron instance (if still in use) is fully patched and configured with all recommended security measures, including domain allow-listing and blocking access to sensitive internal endpoints. However, the primary recommendation is to deprecate Rendertron usage entirely due to its abandoned status.
Align the `timeout` value in the middleware configuration with the `renderingBudgetMs` (or similar) setting on your Rendertron service. Ensure the middleware timeout is sufficiently long to allow the Rendertron service to complete rendering, or handle potential fallback logic for unrendered pages gracefully.
Set the `proxyUrl` in the middleware configuration to the full URL of your Rendertron render endpoint: `app.use(rendertron.makeMiddleware({ proxyUrl: 'http://your-rendertron-url/render' }));`Verify that your `userAgentPattern` regex correctly includes the User-Agents of the bots you want to target (e.g., `new RegExp('googlebot|bingbot', 'i')`). Check your `excludeUrlPattern` to ensure it's not filtering legitimate prerendering requests. Confirm your Rendertron service is running and accessible at the `proxyUrl`.