Static site generation for Cloudflare Pages with prerendered React apps
Overview
prestruct is a minimal build tool that turns your React app into pre-rendered static HTML files perfect for Cloudflare Pages. It handles SEO meta tags, sitemap generation, security headers, and edge performance.
Getting Started
# In an existing Vite + React project
npm i -D prestruct
npx prestruct init # never clobbers existing files
cp ssr.config.example.js ssr.config.js
npx prestruct build
Guides
Performance
Core Web Vitals optimization, bundle sizing, image best practices.SEO
Meta tags, structured data, sitemap, 404 handling, robots directives.Routing
Trailing slashes, dynamic routes, redirects, route configuration.Config
Fullssr.config.js reference: routes, meta, islands, JSON-LD, proxy.
Getting Started
From an empty Vite app to a deployed prerendered site in minutes.CLI
prestruct init / build / validate / clean, flags, and the pipeline steps.
Structured Data
schema.org JSON-LD: Organization, WebSite, breadcrumbs, per-page types.Bot Proxy
Serve crawlers fresh HTML for routes the build cannot prerender (VPS + Worker).Migration
Moving from vendored prerender scripts or another SSR setup to prestruct.API
Engine entry points:prerender(), injectBrand(),
validateConfig(), buildJsonLd(), deep package imports.
Advanced Islands
Load strategies, registry patterns, fallback content, island data flow.Build Optimization
Incremental cache,--force/--clean, CI health-check snapshot.
Why Cloudflare Pages?
- Free - Unlimited requests, sites, and bandwidth
- Edge - 300+ global data centers
- Zero config - Git push to deploy
- Security - Automatic HSTS, CSP, and more
Project Structure
my-site/
|-- ssr.config.js # Route config, meta, schema
|-- public/ # Static assets
|-- src/ # React source
|-- scripts/ # Prerender logic
`-- dist/ # Build output