@fedify/next
v1.9.8
Published
Integrate Fedify with Next.js
Maintainers
Readme
@fedify/next: Integrate Fedify with Next.js
This package provides a simple way to integrate Fedify with Next.js.
[!IMPORTANT] We recommend initializing your app using the
initcommand of the Fedify CLI rather than installing this package directly.
[!IMPORTANT] This package runs Next.js middleware on the Node.js runtime. Therefore, you must use version 15.5 or later, or at least 15.4 canary. For more details, refer to the official documentation of
middleware.
Usage
// --- middleware.ts ---
import { fedifyWith } from "@fedify/next";
import { federation } from "./federation";
export default fedifyWith(federation)();
// This config must be defined on `middleware.ts`.
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" },
],
};