Migrate from Prerender.io

Migrating from Prerender.io to PerfectSearch takes about five minutes. The process involves removing the Prerender middleware, installing the PerfectSearch package, updating your environment variables, and verifying that bots see your content. No cached page migration is needed because PerfectSearch renders fresh snapshots automatically.

How do I uninstall Prerender.io?

Remove the Prerender.io package from your project using your package manager. Then delete or comment out any Prerender middleware configuration from your server setup file. This includes removing the prerender-node middleware call from your Express, Koa, or other server configuration.

bash
npm uninstall prerender-node

Or with bun:

bash
bun remove prerender-node

Remove the middleware configuration from your server file:

diff
// server.js or app.js
- const prerender = require('prerender-node');
- app.use(prerender.set('prerenderToken', 'YOUR_TOKEN'));

How do I install PerfectSearch?

Install the PerfectSearch middleware package and create a middleware.ts file at the root of your Next.js project. The middleware intercepts bot requests at the edge and serves pre-rendered snapshots, while human visitors pass through to your application unchanged.

bash
bun add @perfectsearch/middleware

Create middleware.ts at your project root:

middleware.ts
import { perfectSearchMiddleware } from '@perfectsearch/middleware';

export const middleware = perfectSearchMiddleware({
  apiKey: process.env.PERFECTSEARCH_API_KEY!,
});

export const config = {
  matcher: ['/((?!_next|api|favicon.ico).*)'],
};

Do I need to change my environment variables?

Yes. Replace your Prerender.io token with your PerfectSearch API key. Remove PRERENDER_TOKEN and add PERFECTSEARCH_API_KEY, which is available in the PerfectSearch dashboard under your site's Settings page.

.env.local
# Remove this:
# PRERENDER_TOKEN=your-prerender-token

# Add this:
PERFECTSEARCH_API_KEY=your-api-key-from-dashboard

How do I verify the migration?

Use the PerfectSearch Visibility Test tool to confirm that bots receive fully rendered content. Enter any page URL from your site and the tool will show you exactly what Googlebot, GPTBot, and other crawlers see. Verify that the snapshot contains your complete page content including dynamic sections that rely on JavaScript.

Open the Visibility Test tool →

  • Check that the HTML snapshot contains all visible page content
  • Verify the x-perfectsearch response header is present
  • Test multiple pages including dynamic routes

What about my existing cached pages?

PerfectSearch renders fresh snapshots independently of Prerender.io, so there is no cached content to migrate. When bots first visit your pages after the switch, PerfectSearch queues each URL for rendering and generates new snapshots. If you have a sitemap configured, PerfectSearch discovers and queues all URLs from it during the first crawl cycle, pre-warming your cache automatically.

Pre-warm your cache

To avoid cache misses during the transition, use the POST /v1/snapshot/queue API to queue your most important pages for rendering before switching over. This ensures bots get instant cache hits from the start.