Strata 是一个基于 Rust 的工具,用于将类型化的非交互内容转换为安全、确定的 HTML 片段,供 React Server Components 使用,从而减少大型静态元素树的序列化开销。

Stars

7

7 天增长

暂无数据

Fork 数

0

开放 Issue

0

开源协议

MIT

最近更新

2026-07-29

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它为无需每个元素 React 所有权的大型静态内部提供了一个专门的优化表示,有望在 RSC 框架中提升性能,同时保持强大的安全边界。

适合谁使用

  • React Server Components 开发者
  • 使用 React 构建 CMS/平台的团队
  • 注重性能的 Web 开发者
  • 探索传输优化的 React 框架作者

典型使用场景

  • 在 React Server Component 中渲染大型文章或文档页面
  • 以最小 React 开销提供 CMS 驱动的只读内容
  • 在 React 应用中展示代码清单或大型只读描述

项目优势

  • 基于 Rust 构建,实现快速、确定的 HTML 生成和强大的安全保障
  • 通过允许列表限制标签、属性和 URL 协议,并强制输出大小限制,实现安全设计
  • 生成字节级一致的输出,并附带 BLAKE3 内容哈希,便于缓存集成
  • 与 React Server Components 无缝协作,片段周围的客户端组件保持交互性

使用前须知

  • 处于早期探索阶段——文档格式和 API 可能在 1.0 版本前发生变化
  • 仅适用于非交互内容,片段内不能包含客户端组件、事件处理器或状态
  • 需要每个平台的原生 Rust 二进制文件,在某些部署环境中可能增加复杂性

README 快速开始

Strata

Rust-powered static HTML fragments for React Server Components.

Strata turns typed, non-interactive content into safe, deterministic HTML. React continues to own composition, Client Components and application state. Strata handles static interiors that do not need element-by-element React ownership.

Status: early exploration. The document format and API may change before 1.0.

Why Strata?

Large static content can expand into a much larger serialized React element tree. Strata provides a narrower representation:

typed content → Rust renderer → safe HTML → React-owned boundary

This does not replace React Server Components or Flight. It gives an RSC framework an optimized representation for host-only regions such as articles, documentation, CMS content, code listings and large read-only descriptions.

Background

Strata grew out of the representation-aware transport idea explored in RSC or Raw Data? Designing a Representation-Aware UI Transport. The package is a small experiment around one piece of that idea: carrying safe HTML fragments through a React-owned RSC boundary when a subtree does not need element-by-element React ownership.

Install

pnpm add @farming-labs/strata

Install only @farming-labs/strata. It automatically installs and loads the native binary for the current operating system and CPU architecture. Packages named @farming-labs/strata-* are platform-specific optional dependencies and should not be installed directly.

Render a document

import { render } from "@farming-labs/strata";

const content = {
  type: "document",
  children: [
    {
      type: "element",
      tag: "article",
      attributes: { class: "prose" },
      children: [
        {
          type: "element",
          tag: "h1",
          children: [{ type: "text", value: "Representation-aware UI" }],
        },
        {
          type: "element",
          tag: "p",
          children: [
            {
              type: "text",
              value: "React owns the boundary. Strata renders the interior.",
            },
          ],
        },
      ],
    },
  ],
};

const fragment = render(content);

fragment.html;
fragment.hash;
fragment.nodeCount;
fragment.bytes;

Text and attribute values are escaped. Elements, a

项目描述

RSC Static Renderer: A Performant & Efficient Rust-powered HTML for static React boundaries

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

react
精选
react GitHub avatar

react

React is a JavaScript library for building user interfaces with declarative, component-based, and cross-platform design.

Web 开发前端框架
246,741
TanStack
精选
TanStack GitHub avatar

router

TanStack Router is a type-safe, data-driven React router with built-in caching, prefetching, and nested layouts, while TanStack Start extends it into a full-stack SSR framework.

Web 开发前端框架
14,861
NUber-dev
精选
NUber-dev GitHub avatar

YTubic

YTubic is a fast, responsive, open-source YouTube Music desktop client for Windows, Linux, and macOS that uses direct InnerTube API communication and aggressive caching to provide instant navigation and playback.

Web 开发前端框架
226