@fedify/next

中文文档
2.1.32发布于 2026/11/17MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 9874

Integrate Fedify with Next.js

原始使用文档

@fedify/next: Integrate Fedify with Next.js

Follow @fedify@hollo.social

This package provides a simple way to integrate Fedify with Next.js.

[!IMPORTANT] We recommend initializing your app using the init command of the Fedify CLI rather than installing this package directly.

[!IMPORTANT] This package relies on Next.js request interception on the Node.js runtime. Therefore, you must use Next.js 15.4.6 or later. On Next.js 16, proxy.ts is preferred and middleware.ts is deprecated but still supported. If you switch to proxy.ts, omit runtime: "nodejs" from the exported config, because Proxy always runs on the Node.js runtime. For more details, refer to the official documentation of proxy.

Usage

// --- middleware.ts ---
import { fedifyWith } from "@fedify/next";
import { federation } from "./federation";

export default fedifyWith(federation)();

// This config must be defined in the same file.
export const config = {
  runtime: "nodejs",
  matcher: [
    {
      source: "/:path*",
      has: [
        {
          type: "header",
          key: "Accept",
          value: ".*application\\/((jrd|activity|ld)\\+json|xrd\\+xml).*",
        },
      ],
    },
    {
      source: "/:path*",
      has: [
        {
          type: "header",
          key: "content-type",
          value: ".*application\\/((jrd|activity|ld)\\+json|xrd\\+xml).*",
        },
      ],
    },
    { source: "/.well-known/nodeinfo" },
    { source: "/.well-known/x-nodeinfo2" },
    { source: "/nodeinfo/:path*" },
  ],
};

The matcher decides whether Next.js runs the middleware; fedifyWith() then decides whether Fedify handles the request. NodeInfo paths under /nodeinfo/ are forwarded regardless of their headers. When upgrading an existing application, add { source: "/nodeinfo/:path*" } to its matcher as well as upgrading this package. Requests under this prefix go to Fedify even without a dispatcher, returning 404 Not Found by default.

For a NodeInfo dispatcher outside /nodeinfo/, add its path to matcher and explicitly delegate requests for it to integrateFederation() with the same context data factory and error handlers you use with fedifyWith(). A matcher entry alone does not make fedifyWith() recognize a custom path.

版本与发布记录

@fedify/next 共发布 780 个版本,首次发布于 2025/08/08;过去 12 个月发布了 615 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.32latest2026/11/17今天
2.0.362026/11/17今天
2.5.0-dev.28442026/11/17今天
2.3.16-dev.28452026/11/17今天
2.0.36-dev.28432026/11/17今天
2.3.16-dev.28412026/11/17今天

其他发布通道:pr-405 → 1.9.0-pr.405.1518,pr-421 → 1.9.0-pr.421.1747,pr-474 → 2.0.0-pr.474.1879,pr-478 → 2.0.0-pr.478.1918,pr-479 → 2.0.0-pr.479.1922,pr-490 → 2.0.0-pr.490.2。

关于 @fedify/next 的常见问题

@fedify/next 是什么?

Integrate Fedify with Next.js

如何安装 @fedify/next?

在项目目录运行 npm install @fedify/next,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:next(>=15.4.6 <17)、@fedify/fedify(^2.1.32)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fedify/next 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fedify/next 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fedify/next 可以商用吗?

@fedify/next 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fedify/next 的下载量有多少?

根据 npm 官方下载统计,@fedify/next 在 2026/10/15 – 2026/11/13 这 30 天内被下载 9,874 次,日均约 329 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fedify/next 还在维护吗?

最新版本 2.1.32 发布于 2026/11/17(今天);至今共发布 780 个版本,其中过去 12 个月发布了 615 个;首次发布于 2025/08/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。