Test it

Install your middleware first, then download our open source Prerender server anywhere on your local machine:

Run these commands

git clone https://github.com/prerender/prerender.git
cd prerender
npm install
node server.js

The default port is 3000. Change the server port with export PORT=1337 if needed.

Now you should have a Prerender server running and you should be able to go to  http://localhost:3000/https://www.google.com/ and see the Google homepage.

Try switching out Google’s URL with your own! Any relative links don’t display correctly here, but will be fine once proxied through your server.

Now that we are sure that the Prerender server is working locally, let’s move on to the next step…

Testing your middleware:

Make sure to set your middleware’s prerenderServiceUrl to point to  http://localhost:3000/ instead of our hosted service.

For example, if you’re using the prerender-node middleware:

	.set('prerenderServiceUrl', 'http://localhost:3000/')
	.set('prerenderToken', 'YOUR_TOKEN') );

To see a prerendered page exactly how the crawlers will see it, you can set your User Agent in your browser to Googlebot and visit your URL, or run this on a command line and change www.example.com to your URL:

curl -A Googlebot https://www.example.com/

If you have your middleware set up correctly, you should see your page returned! You’ll know it’s correct if you view the source of your page and see all of the HTML in there instead of just the JavaScript.

That’s it! Don’t forget to add your Prerender Token to your middleware and push it to a staging server so you can test it with our hosted service.

Common Problems:

Are you only getting this?


You are probably on Rails or some other framework that uses blocking I/O. You need to switch to a server (like Unicorn or Puma) that lets you start multiple processes or use non-blocking I/O so that there isn’t a deadlock when Prerender tries to render your page on the fly.

Are you still seeing JavaScript and not the static HTML?

In this case, you view the source of your page that should be prerendered, but it looks the same as a non-prerendered page. This usually happens if your middleware or config isn’t high enough in your code so that it is executed before some other route. Try moving your Prerender middleware configuration higher in your file to see if you can get the Prerender middleware to execute first.

Is your page only partially rendered?

Our Prerender server tries its best to determine when the page is done loading by counting the number of requests in flight. Once the number of requests in flight reaches zero, we wait a short period of time and then save the HTML. If this is saving the page too early, you can use our window.prerenderReady flag to notify the server that your page is ready to be saved.

Put this in your HTML:

<script> window.prerenderReady = false; </script>

When we see  window.prerenderReady set to false, we’ll wait until it’s set to true to save the HTML. Execute this when your page will be ready (usually after ajax calls).

window.prerenderReady = true;
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.