Skip to main content

部分预渲染(实验性)

警告:部分预渲染是一项实验性功能,目前不适用于生产环境。

¥Warning: Partial Prerendering is an experimental feature and is currently not suitable for production environments.

部分预渲染是一项实验性功能,允许预渲染路由的静态部分,并从缓存中提供服务,并通过流式传输动态孔,所有这些都在单个 HTTP 请求中完成。

¥Partial Prerendering is an experimental feature that allows static portions of a route to be prerendered and served from the cache with dynamic holes streamed in, all in a single HTTP request.

部分预渲染在 next@canary 中可用:

¥Partial Prerendering is available in next@canary:

npm install next@canary

你可以通过设置实验性 ppr 标志来启用部分预渲染:

¥You can enable Partial Prerendering by setting the experimental ppr flag:

/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
ppr: true,
},
}

module.exports = nextConfig

很高兴知道:

¥Good to know:

  • 部分预渲染尚不适用于客户端导航。我们正在积极致力于此。

    ¥Partial Prerendering does not yet apply to client-side navigations. We are actively working on this.

  • 部分预渲染仅针对 Node.js 运行时 设计。当你可以立即提供静态 shell 时,不需要使用 Node.js 运行时的子集。

    ¥Partial Prerendering is designed for the Node.js runtime only. Using the subset of the Node.js runtime is not needed when you can instantly serve the static shell.

了解有关 Next.js 学习课程 中部分预渲染的更多信息。

¥Learn more about Partial Prerendering in the Next.js Learn course.