
API和React框架极简,完全类型安全,OpenAPI、RSC、MCP、类型安全客户端,带SSE流式传输
概览
spiceflow 类型安全的 API 和 React Server 组件框架,适用于 Node、Bun 和 Cloudflare Spiceflow 是一个类型安全 API 框架和全栈 React RSC 框架,注重绝对简洁。它能支持所有 JavaScript 运行时:Node.js、Bun 和 Cloudflare Workers。请阅读 GitHub 上的源代码。 - 全栈 React 框架,包含 React 服务器组件(RSC)、服务器动作、布局和自动客户端代码拆分 - 适用于 Node.js、Bun 和 Cloudflare Workers,代码相同 - 通过 Zod 实现基于模式的类型安全验证 - 类型安全取用客户端,对路径参数、查询、正体和响应进行完整推理 - 简单直观的 API,采用 Web 标准的请求与响应 - 可根据路由轻松生成 OpenAPI 规范 - 支持 Model Context 协议,方便将应用与 LLM 连接 - 支持通过服务器发送事件流的异步生成器 - 模块化设计。
概述(AI 翻译)
香料流 Type安全的API和React Server 组件框架,适用于Node、Bun和Cloudflare
Spiceflow 是一个类型安全 API 框架和全栈 React RSC 框架,专注于绝对的简洁性。它能支持所有 JavaScript 运行时:Node.js、Bun 和 Cloudflare Workers。请在 GitHub 上阅读源代码。完整文档保存在 getspiceflow.com。
特色
- 全栈 React 框架,包含 React 服务器组件(RSC)、服务器动作、布局和自动客户端代码拆分
- 适用于所有平台:Node.js、Bun 和 Cloudflare Workers,代码相同
- 通过 Zod 进行基于类型安全模式的验证
- 类型安全取用客户端,对路径参数、查询、正文和响应进行完整推断
- 使用网页标准请求与响应的简单直观 API
- 可以根据你的路由轻松生成OpenAPI规范
- 支持模型上下文协议,方便将应用与大型语言模型(LLM)连接
- 支持通过服务器发送事件进行流媒体的异步生成器
- 模块化设计,带有
.use()用于安装子应用 - 内置OpenTelemetry追踪,禁用时无开销
安装
[!重要] Spiceflow仍处于预发布阶段。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Spiceflow is a type-safe API framework and full-stack React RSC framework focused on absolute simplicity. It works across all JavaScript runtimes: Node.js, Bun, and Cloudflare Workers. Read the source code on GitHub. Full documentation lives at getspiceflow.com.
Features
- Full-stack React framework with React Server Components (RSC), server actions, layouts, and automatic client code splitting
- Works everywhere: Node.js, Bun, and Cloudflare Workers with the same code
- Type safe schema based validation via Zod
- Type safe fetch client with full inference on path params, query, body, and response
- Simple and intuitive API using web standard Request and Response
- Can easily generate OpenAPI spec based on your routes
- Support for Model Context Protocol to easily wire your app with LLMs
- Supports async generators for streaming via server sent events
- Modular design with
.use()for mounting sub-apps - Built-in OpenTelemetry tracing with zero overhead when disabled
Installation
npm install spiceflow@rsc
[!IMPORTANT] Spiceflow is still in pre-release. Install with
spiceflow@rsc, notspiceflow@latest.
AI Agents
To let your AI coding agent know how to use spiceflow, run:
npx -y skills add remorses/spiceflow -g -y
Every documentation page is also available as raw markdown: append .md to any getspiceflow.com URL, for example https://getspiceflow.com/react-data.md.
Basic Usage
API routes return JSON automatically. React pages use .page() and .layout() for server-rendered UI with client interactivity:
import { Spiceflow } from 'spiceflow'
import { Counter } from './counter'
export const app = new Spiceflow()
.get('/api/hello', () => {
return { message: 'Hello, World!' }
})
.layout('/*', async ({ children }) => {
return (
{children}
)
})
.page('/', async () => {
return (
)
})
.page('/about', async () => {
return About
})
app.listen(3000)
Two Ways to Use Spiceflow
Spiceflow works as a standalone API framework or as a full-stack React framework — same router, same type safety, same code.
安装
npx -y skills add remorses/spiceflow -g -y