1. Knowledgebase - Prerender
  2. Integrations
  3. Prerender.io officially maintained integration

What are the steps to integrate Prerender with Cloudflare?

If you want to integrate Prerender into your site, the best approach is to incorporate it into your CDN if one is available. This integration specifically uses the ESM JavaScript syntax in Cloudflare Workers.

Video guide:

 

 

 
Cloudflare UI change
The Workers & Pages menu is moved under Compute(Workers).

Prerender token 

The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.

Copy the Cloudflare worker's source code from this link from here.

It might take a couple of minutes for the integration to start working after the final deployment.

Step-by-step guide

1. Create a new worker

Open your Cloudflare Dashboard and click on Compute(Workers) and select  Workers & Pages on the left side

Cloudflare_int tep 1

Then click on Create on the Worker Overview page.

Cloudflare integration step 2

Then click on the "Create Worker" button.

creat  worker CLoudflare

Give your worker a descriptive name. e.g.: prerender-worker

name worker CF

Click on the Deploy button at the bottom right to initialize the worker.  

deploy CF Worker

2. Add the Prerender worker's code

Click on "Edit Code"

edit worker code

Replace the example code with the worker's source code
Copy the Cloudflare worker's source code from this link.

Add CF worker code

Save the changes by clicking on Deploy.

deploy worker 2

3. Configure the worker

Step back to the previous interface by clicking on your worker's name on the top left. 

0aa1cdd6-b87c-4a26-b797-5b8cf5c1f9fe

Go to Settings and add the zone and routes for your site. 

add routes to worker

Click on +Add at Domains & Routes
add route2Select route
add route3

Add a Route pattern that matches your site and select the Zone where your site is located.

Examples of the Route setting: 

Website Address Type Route Pattern
example.com example.com/*
www.example.com www.example.com/*
Both with/without www *example.com/*
Any subdomain *.example.com/*
Specific subdomain blog.example.com/*
Multiple subdomains (sub1|sub2).example.com/*

 

You can add a route specific to your subdomain. If you want to test Prerender on just one of your domains or subdomains, you can add another route to the worker later.

sav route

Select Failure more:
image-1737708880656Click on Add Route to save the setting.

121cd40e-e3d5-434e-b801-be091bc0bfa7

4. Add the Prerender token as an Environment Variable.

Next to Variables and Secrets, click on +Add

image-1726832957895

Copy your Prerender token from your dashboard

Add your Prerender.io Token from the Security and Access menu.

image-1718876685490

Add a text variable named "PRERENDER_TOKEN" and set its value to the token from your dashboard. Then, click Deploy.

image-1732791320392

image-1726833345336

It might take a couple of minutes for the integration to start working after the final deployment.

It only works in proxy mode.
This integration will only work if Cloudflare is set up as your proxy.
Disable Automatic Signed Exchange (SXGs) in Cloudflare

If you keep the SXGs option enabled, Cloudflare will display the cached version of your website pages to users who click on the page link on the search engine result pages.
However, keep in mind that Prerender is meant to create a static HTML file for search bots, so the rendered version may not be as responsive.
To avoid this issue, we highly recommend disabling this setting in Cloudflare.

You can turn off Automatic Signed Exchanges by going to Speed -> Optimization -> Other (tab) in Cloudflare settings.

image-1707993684604