funstack-static-knowledge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFUNSTACK Static Knowledge
FUNSTACK Static 相关知识
FUNSTACK Static () is a React framework designed to build SPA application that can be deployed as static files to any static hosting service. Its prominent features is support for React Server Components (RSC) which allows optimizing the performance of the application by rendering parts of the UI at build time.
@funstack/staticNote that FUNSTACK Static never runs on the server at runtime (except during development). Server Components are rendered at build time into RSC payloads which are then shipped to the client. The client React runtime can then seamlessly render both Client and Server Components into the DOM.
FUNSTACK Static()是一个React框架,用于构建可部署为静态文件到任意静态托管服务的SPA应用。其突出特性是支持React Server Components(RSC),能够通过在构建时渲染部分UI来优化应用性能。
@funstack/static请注意,FUNSTACK Static在运行时绝不会在服务器上运行(开发阶段除外)。Server Components会在构建时渲染为RSC负载,然后发送到客户端。客户端的React运行时可以无缝地将Client Components和Server Components都渲染到DOM中。
FUNSTACK Static Entrypoint
FUNSTACK Static 入口配置
FUNSTACk Static is served as a Vite plugin. See your app's file for the current configuration. A typical configuration looks like this:
vite.config.tsts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { funstackStatic } from "@funstack/static";
export default defineConfig({
plugins: [
react(),
funstackStatic({
root: "./src/Root.tsx",
app: "./src/App.tsx",
}),
],
});Entrypoint. Here, the option points to the Root component of your application which is responsible for the HTML shell of your application. The option points to the main App component which is the entrypoint for your application's UI.
rootappServer and Client Components. The entrypoint components (Root and App) are server components. FUNSTACK Static follows React's conventions for Server and Client Components; the entrypoint is executed as a Server module. Modules marked with the directive are executed as Client modules. Server modules can import both Server and Client modules, while Client modules can only import other Client modules.
"use client"Server Actions. Note that Server Actions () are NOT supported in FUNSTACK Static, as there is no server runtime deployed.
"use server"FUNSTACK Static以Vite插件的形式提供。查看你应用中的文件即可看到当前配置。典型配置如下:
vite.config.tsts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { funstackStatic } from "@funstack/static";
export default defineConfig({
plugins: [
react(),
funstackStatic({
root: "./src/Root.tsx",
app: "./src/App.tsx",
}),
],
});入口文件:这里的选项指向应用的Root组件,它负责应用的HTML外壳。选项指向主App组件,这是应用UI的入口。
rootappServer与Client组件:入口组件(Root和App)是Server组件。FUNSTACK Static遵循React关于Server和Client组件的约定:入口作为Server模块执行。标记有指令的模块作为Client模块执行。Server模块可以导入Server和Client模块,而Client模块只能导入其他Client模块。
"use client"Server Actions:请注意,FUNSTACK Static不支持Server Actions(),因为它没有部署服务器运行时。
"use server"FUNSTACK Static Docs
FUNSTACK Static 文档
More detailed documentation about FUNSTACK Static (including API references and best practices) can be found inside at:
node_modulesnode_modules/@funstack/static/dist/docs/index.md关于FUNSTACK Static的更详细文档(包括API参考和最佳实践)可以在目录下的以下路径找到:
node_modulesnode_modules/@funstack/static/dist/docs/index.md