Token导航 LogoToken导航TokenDH.com
开发external-servicegithub未标认证来源可访问许可证需确认审计通过

react-selective-hydrationReact selective hydration 开发

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

6,797

周安装

289

GitHub Stars

173

下载量

2,381
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-selective-hydration(React selective hydration 开发)
来源仓库:https://github.com/patternsdev/skills
仓库路径:skills/react-selective-hydration
安装命令:
npx skills add https://github.com/patternsdev/skills --skill react-selective-hydration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/patternsdev/skills --skill react-selective-hydration

简介

辅助 React 选择性水合(Selective Hydration)开发实践。

  • 适用于优化服务端渲染页面的客户端激活性能。react-selective-hydration 属于开发类 Skill,可作为该场景下的辅助能力补充。
  • 可生成或审查按需水合、减少交互延迟的相关代码。
  • 需结合项目 SSR/CSR 架构和框架版本使用,避免误用。
  • 涉及 hydration 逻辑改动时,应配合性能测试确认效果。

SKILL.md

Selective Hydration

In previous articles, we covered how SSR with hydration can improve user experience. React is able to (quickly) generate a tree on the server using the renderToString method that the react-dom/server library provides, which gets sent to the client after the entire tree has been generated. The rendered HTML is non interactive, until the JavaScript bundle has been fetched and loaded, after which React walks down the tree to hydrate and attaches the handlers.

However, this approach can lead to some performance issues due to some limitations with the current implementation.

When to Use

  • Use this when you want to make parts of your SSR page interactive before all JavaScript has loaded
  • This is helpful when slow components (e.g., data-fetching components) are blocking the entire page's hydration

Instructions

  • Use Suspense boundaries to delineate independently hydratable chunks of UI
  • Use renderToPipeableStream (Node) or renderToReadableStream (edge) for streaming SSR
  • Place heavy data-fetching components inside Suspense so they don't delay sibling hydration
  • Ensure critical interactive components are not inside long-lived loading fallbacks
  • Use hydrateRoot (React 18+) to benefit from selective hydration

Details

Before the server-rendered HTML tree is able to get sent to the client, all components need to be ready. This means that components that may rely on an external API call or any process that could cause some delays, might end up blocking smaller components from being rendered quickly.

Besides a slower tree generation, another issue is the fact that React only hydrates the tree once. This means that before React is able to hydrate any of the components, it needs to have fetched the JavaScript for all of the components before it's able to hydrate any of them. This means that smaller components (with smaller bundles) have to wait for the larger components's code to be fetched and loaded, until React is able to hydrate anything on your website. During this time, the website remained non-interactive.

React 18 solves these problems by allowing us to combine streaming server-side rendering with a new approach to hydration: Selective Hydration!

Instead of using renderToString, modern React SSR uses renderToPipeableStream() on Node runtimes or renderToReadableStream() on Web Stream runtimes.

These APIs, in combination with hydrateRoot() and Suspense, make it possible to start streaming HTML without having to wait for the larger components to be ready. This means that we can lazy-load components when using SSR without blocking the hydration of the rest of the page.

The Comments component, which earlier slowed down the tree generation and TTI, is now wrapped in Suspense. This tells React to not let this component slow down the rest of the tree generation. Instead, React inserts the fallback components as the initially rendered HTML, and continues to generate the rest of the tree before it's sent to the client.

In the meantime, we're still fetching the external data that we need for the Comments component.

Selective hydration makes it possible to already hydrate the components that were sent to the client, even before the Comments component has been sent!

Once the data for the Comments component is ready, React starts streaming the HTML for this component, as well as a small <script> to replace the fallback loader.

React starts the hydration after the new HTML has been injected.

React 18 fixes some issues that people often encountered when using SSR with React.

Streaming rendering allows you to start streaming components as soon as they're ready, without risking a slower FCP and TTI due to components that might take longer to generate on the server.

Components can be hydrated as soon as they're streamed to the client, since we no longer have to wait for all JavaScript to load to start hydrating and can start interacting with the app before all components have been hydrated.

Source

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.7%
按下载量换算826

Claude

29.58%
按下载量换算704

Cursor

19.31%
按下载量换算460

Gemini CLI

8.57%
按下载量换算204

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills