How do I integrate Prerender.io with Node.js and Express.js?
Connect Prerender.io to your Express.js server so AI crawlers and search engines receive fully rendered HTML.
TL;DR
prerender-node middleware in your Express.js application, add your Prerender.io token, and restart your server. The middleware detects AI crawlers and search engine bots automatically and routes their requests through Prerender.io's rendering service. Your website visitors are not affected.⚠️ This integration is for Express.js servers that handle all incoming connections, not just API calls. It cannot be installed directly into a React, Angular, or Vue project. If your frontend framework handles routing on its own, see how to integrate Prerender.io with a Single Page Application.
ℹ️ Prefer a video walkthrough? A video guide is available at the top of this article.
Video guide:
Step 1: Log in to your Prerender.io dashboard and copy your token.
You will need your Prerender.io token for the next step. Log in to your Prerender.io dashboard and find your token under the Security and Access menu.
Copy the token and keep it ready.
Step 2: Install the prerender-node middleware.
Open a terminal in your Express.js project directory and run:
npm install prerender-node --save
This adds the prerender-node package to your project. The source code is available on GitHub.
Step 3: Add the middleware to your Express.js application.
In your main server file (commonly app.js or server.js), add the following line before any route handlers:
app.use(require('prerender-node').set('prerenderToken', 'YOUR_TOKEN'));
Replace YOUR_TOKEN with the Prerender.io token you copied in Step 1.
⚠️ Do not commit your real token to a public repository. Use an environment variable (e.g., process.env.PRERENDER_TOKEN) to keep it secure.
Step 4: Restart your application.
Save your changes, then restart your Express.js server so the middleware takes effect:
npm start
If you use a process manager like pm2:
pm2 restart your-app-name
Step 5: verify your integration is working.
After restarting, confirm that Prerender.io is intercepting crawler requests and serving rendered HTML.
- In Chrome DevTools, change your browser's user-agent string to a known crawler (e.g.,
Googlebot) and visit one of your pages. - In the Network tab, check the response headers for the
x-prerender-request-idheader. When using the hosted Prerender.io service, this header confirms Prerender.io is serving the page. - Open your Prerender.io dashboard and verify that cached pages begin appearing.
✅ Your integration is working when a simulated bot request returns an
x-prerender-request-idresponse header (hosted Prerender.io service) and cached pages appear in your Prerender.io dashboard.
For detailed verification steps, see how to verify your Prerender.io integration.
If you see the message Prerender Integration Not Detected, follow the troubleshooting guide for integration detection errors.
If the integration works on your homepage but not on other pages, test those pages individually using the same verification steps. Missing Prerender.io headers on specific pages usually means the middleware is not intercepting requests for those routes. Check that the middleware is added before all route handlers in your server file.
Related articles
- How to integrate Prerender.io with React, Angular, or Vue
- Available integrations
- How to add additional AI crawlers and bots
💬 Still need help? If your integration is not working after following these steps, our support team can help. Include any error messages, the steps you have already tried, and screenshots if applicable. → Contact us at support@prerender.io