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

Next.js静态导出时触发‘Server Actions are not supported with static export’错误的排查求助

Next.js静态导出时触发‘Server Actions are not supported with static export’错误的排查求助

我用Next.js搭配Sanity.io客户端做了一个简单的餐厅网站,现在想把它静态导出成纯HTML+CSS+JS文件,这样就不用依赖容器或者Vercel来部署了。但执行导出操作的时候,一直弹出错误:

"Server Actions are not supported with static export"

我已经给项目里的每一个文件都加上了"use client";指令,而且我从一开始就没打算用任何Server Actions功能,但麻烦的是错误信息里完全没指出到底哪里触发了这个问题,我连要改哪里都不知道。

这是我的next.config.ts配置文件:

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  output: "export",
  images: {
    unoptimized: true,
    remotePatterns: [
      {
        protocol: "https",
        hostname: "cdn.sanity.io",
      },
      {
        protocol: "http",
        hostname: "cdn.sanity.io",
      },
    ],
  },
  trailingSlash: true,
};

export default nextConfig;

有没有人遇到过类似的情况?或者有什么方法能定位到项目里隐性触发Server Actions的地方?比如是不是Sanity的客户端调用里有什么默认会触发Server Actions的配置?

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.08 12:10:29