Skip to content

JoinDataCops/react-prerender-datacops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ React Prerender DataCops

React Prerender DataCops - Zero-cost bot prerendering for AI-generated apps

Zero-cost bot prerendering for React SPAs. Make AI-generated apps crawlable in 10-30 minutes.

License: MIT Cloudflare Workers React

Built by DataCops β€” First-party analytics, bot filtering, and conversion APIs that recover the 15–60% of session data that ad blockers silently drop.


Demo

This skill has been used on over 20+ projects. Here are some demo results

ChatGPT

ChatGPT

Claude

Claude

Gemini

Gemini

Google Search Console demo result

This site was published 2 weeks ago; here are the SEO bot performance results.

Google Search Console

🚨 The Problem

1️⃣ AI Platforms Build Apps Crawlers Can't See

10M+ apps on Lovable. Millions more on Bolt.new, v0, Cursor.

Every single one delivers this to Google:

<div id="root"></div>

Crawlers don't execute JavaScript. They see empty HTML.

  • ❌ No search traffic
  • ❌ No social previews
  • ❌ No AI citations (ChatGPT, Perplexity, Claude)

2️⃣ Next.js Is Useless Here

What React does (everything AI apps need):

What AI Apps Need React SPA Next.js
Component logic βœ… βœ…
State management βœ… βœ…
Routing βœ… (React Router) βœ…
Styling βœ… (Tailwind) βœ…
Data fetching βœ… (React Query) βœ…
Crawler HTML ❌ βœ…

The ONLY gap: Crawlers need prerendered HTML.

Next.js "solution":

  • Rewrite entire app (2-4 weeks)
  • Vercel lock-in ($20-100/month)
  • Complex SSR/ISR/RSC concepts

This solution:

  • Add edge prerendering (10-30 minutes depends on your content volume)
  • Cloudflara free hosting ($0)
  • Zero new concepts

React does everything. This fills the crawler gap. Next.js is unnecessary.


3️⃣ Startups Waste Money on "AEO Content Optimization"

Hundreds of startups selling AEO content tools. They all ignore one fact:

Crawlers can't see your content if your HTML is empty.

What Startups Sell What They Ignore
"Optimize for AI search" Crawlers see <div id="root"></div>
"Structure your content for LLMs" No HTML = No content to structure
"Add schema markup" Schema requires HTML first

The hierarchy:

1. Crawlable HTML ← You are here (broken)
2. Content quality ← AEO tools help here
3. Schema/meta tags ← Only works if #1 exists

You can't optimize content that doesn't exist to crawlers.

This is an infrastructure problem, not a content problem.

AEO tools assume your site is crawlable. AI-generated React apps are not.


✨ The Solution

How It Works

User visits site     β†’  Normal React SPA
Crawler visits site  β†’  Prerendered HTML from cache

That's it.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   1. Request arrives           β”‚
β”‚   (your-site.com/about)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
     β”‚ Cloudflare  β”‚
     β”‚ Middleware  β”‚
     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
            β”‚
      Is it a bot?
            β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
    β”‚               β”‚
   YES             NO
    β”‚               β”‚
    β–Ό               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Fetch  β”‚    β”‚ Serve   β”‚
β”‚ cached β”‚    β”‚ normal  β”‚
β”‚ HTML   β”‚    β”‚ SPA     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Simple:

  1. Cloudflare detects bots
  2. Bots get prerendered HTML
  3. Humans get normal SPA
  4. Cache refreshes automatically

What You Need

Component Options
Edge Cloudflare Pages (free)
Database Postgres, MongoDB, Redis, Supabase, Firebaseβ€”any
Backend Node, Python, Go, Lambdaβ€”any HTTP API
Scheduler Cron, GitHub Actionsβ€”any

You choose your stack. We provide the edge logic.


⚑ Quick Start

For AI developers: Follow the SKILL.md guide.

It has complete step-by-step instructions for:

  • Supabase + PostgreSQL
  • Node.js + Express
  • Python + FastAPI
  • Firebase + Firestore
  • AWS Lambda + DynamoDB

Choose your stack. Follow the guide. Done in 30 minutes.

The 3 Steps

1. Add Cloudflare middleware (5 min)
2. Create API endpoints (15 min)
3. Seed cache & schedule refresh (10 min)

Everything you need is in SKILL.md.


πŸ”§ Advanced Features

Script Service: Dynamic <script> Injection

Problem: React SPAs can't easily add Google Analytics, Facebook Pixel, or consent managers without modifying source code.

Solution: The Script Service is a backend endpoint that returns scripts to inject:

// GET /api/script-service returns:
{
  "head": [
    "<script async src='https://www.googletagmanager.com/gtag/js?id=GA_ID'></script>",
    "<script>window.dataLayer = window.dataLayer || [];</script>"
  ],
  "body": [
    "<script>!function(f,b,e,v,n,t,s){...}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');</script>"
  ]
}

The Cloudflare middleware fetches this and injects scripts into every HTML responseβ€”for both bots and humans.

Why this matters:

  • βœ… Add analytics without editing React code
  • βœ… Scripts survive AI platform rebuilds
  • βœ… Centralized script management
  • βœ… First-party script context (bypass ad blockers)

Automated Sitemap Generation

Generate and serve dynamic sitemaps:

<!-- /sitemap.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://your-site.com/</loc>
    <lastmod>2026-03-04</lastmod>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://your-site.com/about</loc>
    <lastmod>2026-03-04</lastmod>
    <priority>0.8</priority>
  </url>
</urlset>

Automatically updated when cache refreshes.


πŸ“Š vs. Alternatives

Complete Comparison

Feature This Solution Next.js Migration Prerender.io Custom SSR
Monthly Cost $0 (Cloudflare free tier) $20–$100+ $15–$200 Variable
Setup Time 30 minutes 2–4 weeks 1 day 1–3 months
Code Changes Zero Complete rewrite Minimal config Extensive
Vendor Lock-in None Vercel-dependent Yes None
Bot Response Time ~50ms (edge cache) ~200-500ms (SSR) ~100ms Variable
Works with AI platforms βœ… Yes ❌ Requires rewrite ⚠️ Config needed ❌ No
Backend Flexibility βœ… Any DB, any API ❌ Vercel-optimized βœ… Yes ⚠️ Complex
Global Edge Network βœ… 300+ cities Regional servers Varies Your infra
User Experience Pure SPA (instant) SSR + hydration Pure SPA Varies
Cache Control βœ… You own it ISR config 3rd party You own it
Script Injection βœ… Dynamic Manual Limited Manual

Cost Breakdown (Annual)

Solution Year 1 Cost Ongoing Annual
This System $0 $0
Next.js (Vercel Pro) $240–$1,200 $240–$1,200
Prerender.io (Growth) $600–$2,400 $600–$2,400
Custom SSR Dev Time $10,000+ $2,000+ (maintenance)

5-year savings vs. Next.js: $1,200 - $6,000


🎯 Use Cases & Results

Who This Is For

βœ… Lovable/Bolt/v0 apps β€” Make your AI-generated app discoverable
βœ… React SPA developers β€” Add SEO without framework migration
βœ… Agencies β€” Ship client sites with proper crawler visibility
βœ… Startups β€” Launch fast, get search traffic immediately
βœ… Content sites β€” Ensure AI search engines can cite you
βœ… SaaS products β€” Public pages need organic discovery

After Deploying This System

Before After
❌ Google sees <div id="root"></div> βœ… Full content indexed with meta tags
❌ Social shares show blank previews βœ… Rich preview cards with images
❌ Zero organic search traffic βœ… Search engine visibility restored
❌ AI can't cite or recommend you βœ… ChatGPT/Claude/Perplexity can reference you
❌ Manual script management βœ… Centralized script injection
❌ Static or missing sitemaps βœ… Auto-generated, always current

Real-World Metrics

Typical results after deployment:

  • πŸ“ˆ Search visibility: 0% β†’ 85%+ of pages indexed within 2 weeks
  • πŸ“ˆ Social engagement: Blank cards β†’ Rich previews = 3-5x higher click-through
  • πŸ“ˆ Organic traffic: $0 β†’ Measurable within 30 days
  • πŸ“ˆ AI citations: Not discoverable β†’ Cited by ChatGPT/Perplexity

πŸ“š What's Included

File Purpose
README.md This document
SKILL.md Complete technical guide with multi-stack examples
middleware.ts Cloudflare Pages edge middleware (bot detection & routing)
database-schema.sql PostgreSQL schema (adapt for your database)
edge-functions/prerender.ts Supabase reference: cache lookup
edge-functions/generate-prerender-cache.ts Supabase reference: HTML builder
edge-functions/generate-sitemap.ts Supabase reference: dynamic sitemap
edge-functions/serve-sitemap.ts Supabase reference: static sitemap delivery
edge-functions/manage-cron-job.ts Supabase reference: cache refresh scheduler
edge-functions/script-service.ts Supabase reference: dynamic script injection

Note: The edge-functions/ folder contains Supabase/Deno reference implementations. If you use a different backend (Node, Python, Go, etc.), implement the same endpoints in your stack. The SKILL.md provides examples for multiple stacks.


πŸš€ Implementation Guide

For Different Stacks

The system is backend-agnostic by design. Choose your stack:

Full implementations in SKILL.md for:

  • βœ… Supabase + PostgreSQL
  • βœ… Node.js + Express + PostgreSQL
  • βœ… Python + FastAPI + PostgreSQL
  • βœ… Firebase + Firestore
  • βœ… AWS Lambda + DynamoDB
  • βœ… Any other backend with HTTP + database

The pattern is always:

  1. Cloudflare middleware detects bots
  2. Fetches cached HTML from YOUR backend
  3. YOUR backend stores HTML in YOUR database
  4. YOUR scheduler refreshes the cache

Universal. Stack-agnostic. You stay in control.


🀝 Contributing

We welcome contributions! This system is stack-agnostic by designβ€”help us add more implementations.

Ways to Contribute

  • βœ… Add backend implementations for new stacks (Ruby, PHP, Rust, etc.)
  • βœ… Improve bot detection patterns
  • βœ… Share success stories and metrics
  • βœ… Report issues or edge cases
  • βœ… Improve documentation

See CONTRIBUTING.md for guidelines.


πŸ“œ License

MIT License β€” Use, fork, and deploy freely.

See LICENSE file for full terms.


🏒 Built by DataCops

This system is built and maintained by DataCops β€” the first-party analytics platform that recovers the 15–60% of web data that ad blockers and ITP silently drop.

Our products:

  • First-party analytics that bypass ad blockers
  • Bot filtering and traffic quality intelligence
  • No-code conversion APIs for clean data to every platform
  • First-party consent management from your own domain

We distribute clean conversion data to Google Ads, Facebook, TikTok, and every CRMβ€”data that ad blockers can't touch.


❓ FAQ

Is this really free?

Yes. Cloudflare Pages free tier includes middleware. Your backend costs depend on your stack choice, but most have generous free tiers (Supabase, Firebase, Railway, etc.).

Does this work with [my framework]?

Yes. If it's a client-side SPA (React, Vue, Svelte, Angular), this works. The system is framework-agnostic.

Do I need to modify my React code?

No. Zero code changes to your application. This is pure infrastructure.

What about performance for real users?

Humans get the normal SPAβ€”nothing changes. Only bots get prerendered HTML. No performance impact on user experience.

Can I use this with Next.js?

Technically yes, but unnecessary. Next.js already does SSR. This system is for SPAs that don't have server-side rendering.

How often should cache refresh?

Depends on your content. Static sites: daily. News sites: hourly. E-commerce: every 6 hours. You control the schedule.

What if my site has 10,000 pages?

The system scales. Database storage is cheap. Cloudflare edge cache is global. Just ensure your backend can handle the cache generation load.

Does this work for dynamic content?

Yes. The cache stores a snapshot. For highly dynamic content (stock prices, live scores), you might want shorter refresh intervals or conditional caching logic.

Can I see an example?

Full working examples in SKILL.md across multiple backend stacks with complete code.


The crawler detection layer (Cloudflare) is universal.
The backend is yours to choose.
Zero vendor lock-in. You own your infrastructure.


πŸ”— Links


Built for the AI development era. Deploy in 30 minutes. Own your infrastructure forever.