Express middleware for the rendertron service.
Last updated 8 months ago by dfrechette .
Apache-2.0 · Original npm · Tarball · package.json
$ cnpm install @dfrechette/rendertron-middleware 
SYNC missed versions from official npm registry.

Build status NPM version


An Express middleware for Rendertron.

Rendertron is a server which runs headless Chrome and renders web pages on the fly, which can be set up to serve pages to search engines, social networks and link rendering bots.

This middleware checks the User-Agent header of incoming requests, and if it matches one of a configurable set of bots, proxies that request through Rendertron.


$ npm install --save express @dfrechette/rendertron-middleware
const functions = require('firebase-functions');
const express = require('express');
const app = express();
const rendertron = require('rendertron-middleware');

const BOTS = rendertron.botUserAgents.concat('googlebot');
const BOT_UA_PATTERN = new RegExp(BOTS.join('|'), 'i');

  proxyUrl: 'http://my-rendertron-instance/render',
  userAgentPattern: BOT_UA_PATTERN,
  host: 'my-fancy-domain.com', // optional
  protocol: 'https' // optional



The makeMiddleware function takes a configuration object with the following properties:

Property Default Description
proxyUrl Required Base URL of your running Rendertron proxy service.
host req.get('host') Specify an external domain to use for the URL sent to the rendertron service. Ex. Firebase hosting that rewrite queries to a cloud function, the req.get('host') would be the cloud function domain and not the website.
protocol req.protocol Force a specific protocol to use when building the URL to be pass to rendertron
userAgentPattern A set of known bots that benefit from pre-rendering. Full list. RegExp for matching requests by User-Agent header.
excludeUrlPattern A set of known static file extensions. Full list. RegExp for excluding requests by the path component of the URL.
injectShadyDom false Force the web components polyfills to be loaded. Read more.
timeout 11000 Millisecond timeout for the proxy request to Rendertron. If exceeded, the standard response is served (i.e. next() is called). This is not the timeout for the Rendertron server itself. See also the Rendertron timeout.

Current Tags

  • 0.1.8                                ...           latest (8 months ago)

3 Versions

  • 0.1.8                                ...           8 months ago
  • 0.1.7                                ...           8 months ago
  • 0.1.6                                ...           8 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (2)
Dev Dependencies (8)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |