跳到正文
Skillpedia
网站与界面(前端)75k · #3037

streaming-html

它能做什么

这个技能检查服务器渲染代码,看 HTML 是分块流式发送,还是等全部准备好才发送,并在有帮助的地方建议使用流式输出。它面向开发服务器渲染网站的开发者,例如 Next.js 或 Node.js 应用。

适用场景

  • ✓你请智能体检查服务器渲染的页面是否采用流式传输 HTML 的时候。
  • ✓由于一个缓慢的数据请求拖住了所有内容,页面的首字节到达得很慢的时候。
  • ✓你使用 Next.js App Router 或 Node.js 处理程序,并想确认流式输出设置正确的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/streaming-html/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/streaming-html/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的服务器渲染页面要很久才显示内容,因为一个慢查询拖住了全部。请帮我设置流式输出吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查渲染代码是否在发送 HTML 前等待所有数据。然后它会在慢速数据周围添加 Suspense 边界,或使用流式 API,使页面顶部立即发送。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Stream HTML to the browser before the full response is ready

Traditional SSR waits for all data fetches to complete before sending a single byte of HTML, which means the browser cannot parse, discover subresources, or render anything until the slowest data query finishes. Streaming decouples the delivery of above-fold content from slow database queries and third-party API calls, dramatically improving perceived performance and LCP.

Quick Reference

  • Streaming sends HTML in chunks as it is generated instead of waiting for the full response
  • React renderToPipeableStream and Next.js App Router stream by default when you use Suspense
  • Place Suspense boundaries around slow data dependencies to flush above-fold HTML immediately
  • Monitor TTFB in Lighthouse — values above 600ms are a sign that streaming is not being used

Check

Examine this server-side rendering implementation to determine whether HTML is streamed in chunks or buffered until fully generated before sending to the client.

Fix

Refactor the SSR implementation to use renderToPipeableStream with Suspense boundaries around slow data fetches, or use ReadableStream in a Node.js handler, so that above-fold HTML is flushed to the client immediately.

Explain

Explain how streaming HTML improves TTFB and FCP by decoupling the delivery of fast content from slow server-side data dependencies.

Code Review

Review server entry points and page components for renderToString calls, missing Suspense boundaries around data-fetching components, and use of await on slow queries before returning a response.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/performance/streaming-html

常见问题

流式输出对访客有什么改变?

这个技能说,即使最慢的数据查询还未完成,浏览器也可以先解析、查找资源并显示内容。

Next.js 中流式输出是自动的吗?

这个技能说,使用 Suspense 时,App Router 默认进行流式输出。

我应该关注哪个数字?

这个技能建议在 Lighthouse 中关注首字节时间,并说超过 600 毫秒可能表明缺少流式输出。

详情

作者的原始描述

Use when reviewing server-side rendering setup, Next.js App Router pages, or Node.js HTTP handlers to verify that HTML is streamed incrementally rather than buffered until completion.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#3037
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能