You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js v12.3.4中如何为Page Router设置Edge Runtime?

Next.js v12.3.4 Page Router 配置 Edge Runtime 正确方法

在 Next.js v12.3.4 的 Page Router 模式下,设置 Edge Runtime 的语法和 App Router 不同,你之前用的export const runtime = 'edge'只适用于 App Router,所以才会在 Vercel 上依然以 Serverless 函数渲染。

正确的配置方式是通过导出config对象来指定运行时:

export const config = {
  runtime: 'edge'
}

export default function YourPage() {
  return <div>你的页面内容</div>
}

部署到 Vercel 后,可以通过以下方式确认是否生效:

  • 进入项目的「Functions」页面
  • 找到对应页面的函数条目,查看其类型是否标注为「Edge Function」

另外需要注意:如果你的页面代码中使用了 Edge Runtime 不支持的 Node.js 原生 API(比如fs、child_process这类),Vercel 会自动将函数降级为 Serverless 类型,需要确保代码符合 Edge Runtime 的限制。

内容的提问来源于stack exchange,提问作者hcentelles

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 06:29:51