Scripts2026年7月21日·1 分钟阅读

React Static — Progressive Static Site Generator for React

A fast, lightweight static site generator for React that pre-renders every page to static HTML for performance and SEO, while hydrating to a fully interactive single-page app on the client.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
React Static Overview
直接安装命令
npx -y tokrepo@latest install 48b9f1c1-8548-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

React Static is a progressive static site generator built for React. It generates a pre-rendered HTML file for every route at build time, delivering fast initial loads and strong SEO. Once loaded in the browser, the site hydrates into a fully interactive React single-page application with client-side routing. It bridges the gap between static site speed and React app interactivity.

What React Static Does

  • Pre-renders every route to static HTML at build time for instant page loads
  • Hydrates to a full React SPA with client-side navigation after initial load
  • Supports dynamic data fetching at build time from any source (APIs, CMSs, files)
  • Code-splits automatically per route for optimal bundle sizes
  • Generates a sitemap and handles meta tags for SEO out of the box

Architecture Overview

React Static uses a static.config.js file where you define routes and data-fetching functions. At build time, it calls each route's getData() function, renders the React component tree to HTML using ReactDOMServer, and writes static HTML files. It also generates a JSON data manifest so the client can fetch route data without re-calling APIs. The client-side runtime hydrates the static HTML and uses React Router for subsequent navigation, prefetching route data on link hover.

Self-Hosting & Configuration

  • Create a project with npx react-static create using a starter template
  • Define routes in static.config.js with a getRoutes function returning route objects
  • Each route can have a getData function that fetches content at build time
  • Build with react-static build which outputs to a dist/ folder
  • Deploy the dist/ folder to any static hosting (Netlify, Vercel, S3, GitHub Pages)

Key Features

  • Automatic code splitting per route with zero configuration
  • Link prefetching on hover for near-instant page transitions
  • Supports any data source (REST APIs, GraphQL, headless CMS, markdown files)
  • Hot module reloading in development for fast iteration
  • Plugin system for integrating with markdown, SASS, TypeScript, and other tools

Comparison with Similar Tools

  • Next.js — full-stack React framework with SSR and SSG; React Static is purely static with a simpler model
  • Gatsby — plugin-rich static generator with GraphQL data layer; React Static uses plain JavaScript data fetching
  • Astro — multi-framework SSG with partial hydration; React Static is React-only with full hydration
  • Remix — server-rendered React framework; React Static generates static files with no runtime server

FAQ

Q: Can I use it with a headless CMS? A: Yes. Fetch data from any CMS (Contentful, Strapi, Sanity) in your getData functions. The data is baked into the static build.

Q: Does it support dynamic routes? A: Yes. Define parameterized routes in getRoutes and generate a page for each item. All pages are still statically rendered at build time.

Q: How does it handle client-side navigation? A: After hydration, React Static uses React Router for client-side transitions. Route data is prefetched as JSON files, so navigation feels instant.

Q: Is it still actively maintained? A: React Static is stable and feature-complete. While development has slowed, the existing feature set covers most static site use cases and the codebase remains functional with current React versions.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产