Skip to content

Add Nuxt as a web framework option in fedify init#675

Draft
2chanhaeng wants to merge 9 commits intofedify-dev:mainfrom
2chanhaeng:init-nuxt
Draft

Add Nuxt as a web framework option in fedify init#675
2chanhaeng wants to merge 9 commits intofedify-dev:mainfrom
2chanhaeng:init-nuxt

Conversation

@2chanhaeng
Copy link
Copy Markdown
Contributor

Add Nuxt as a web framework option in fedify init

Depends on #674.

Changes

@fedify/init

  • Added Nuxt as a selectable web framework in fedify init.
    Users can now scaffold a new Fedify project with Nuxt integration
    across all supported package managers (npm, pnpm, yarn, Bun, Deno).

New files

  • src/webframeworks/nuxt.ts: WebFrameworkDescription for Nuxt,
    including nuxi init scaffolding command, dependency resolution for
    both Node.js and Deno environments, and template file mapping.
  • src/templates/nuxt/nuxt.config.ts.tpl: Minimal Nuxt config
    template with SSR disabled and devtools enabled.
  • src/templates/nuxt/server/federation.ts.tpl: Federation
    instance setup with MemoryKvStore and a basic actor dispatcher.
  • src/templates/nuxt/server/logging.ts.tpl: LogTape
    configuration for Nuxt and Fedify loggers.
  • src/templates/nuxt/server/middleware/federation.ts.tpl: Nitro
    event handler that delegates requests to federation.fetch(),
    falling through to Nuxt on 404.

Modified files

  • src/const.ts: Added "nuxt" to the WEB_FRAMEWORK array.
  • src/webframeworks/mod.ts: Imported and registered the Nuxt
    framework description.
  • src/json/deps.json: Added @nuxt/kit, h3, nuxi, and
    nuxt version pins.
  • src/test/port.ts: Added port replacement logic for Nuxt
    (injects nitro.port into nuxt.config.ts).

Co-Authored-By: GPT-5.4

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e5649acc-d537-45a1-884b-154699b40195

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@issues-auto-labeler issues-auto-labeler bot added component/cli CLI tools related component/federation Federation object related component/integration Web framework integration labels Apr 13, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the @fedify/nuxt package to provide seamless integration between Fedify and the Nuxt framework, alongside updates to the fedify init tool for project scaffolding. The review feedback correctly identifies a critical bug in the Nuxt middleware template where the request body is ignored during manual Request construction, suggesting the use of toWebRequest from h3 as a fix. Furthermore, the feedback recommends enabling the @fedify/nuxt module by default in generated projects to simplify the setup and points out a typo in the Node.js type definitions version.

Comment on lines +5 to +16
// Construct the full URL from headers
const proto = event.headers.get("x-forwarded-proto") || "http";
const host = event.headers.get("host") || "localhost";
const url = new URL(event.node.req.url || "", `${proto}://${host}`);

const request = new Request(url, {
method: event.node.req.method,
headers: event.node.req.headers as Record<string, string>,
body: ["GET", "HEAD", "DELETE"].includes(event.node.req.method)
? undefined
: undefined,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The manual construction of the Request object is incomplete and contains a bug: the body is always set to undefined (lines 13-15), which will break ActivityPub inbox listeners that rely on POST requests.

Using toWebRequest(event) from h3 is the recommended approach as it correctly handles URL construction (including proxy headers), headers, and body streaming, while significantly simplifying the code.

  const request = toWebRequest(event);

devDependencies: {
...defaultDevDependencies,
"typescript": deps["npm:typescript"],
"@types/node": deps["npm:@types/node@25"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The key npm:@types/node@25 appears to be a typo. Node.js versions currently go up to 23, and the monorepo uses ^22.17.0 (as seen in pnpm-workspace.yaml). This will likely result in an undefined value if the key does not exist in deps.json, causing issues in the scaffolded project.

      "@types/node": deps["npm:@types/node"],

@@ -0,0 +1,24 @@
import { defineEventHandler } from "h3";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Import toWebRequest from h3 to simplify request conversion and ensure the request body is correctly handled for all HTTP methods.

import { defineEventHandler, toWebRequest } from "h3";

Comment on lines +2 to +5
export default defineNuxtConfig({
ssr: false,
devtools: { enabled: true },
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The @fedify/nuxt module is installed as a dependency but not enabled in the generated configuration. Enabling the module is the preferred integration method as it provides features like deferred 406 Not Acceptable handling and automatic middleware registration.

If the module is enabled, the manual middleware in server/middleware/federation.ts becomes redundant and should be removed from the template set in packages/init/src/webframeworks/nuxt.ts to avoid duplicate request handling.

export default defineNuxtConfig({
  modules: ["@fedify/nuxt"],
  ssr: false,
  devtools: { enabled: true },
});

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 42.27642% with 71 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/init/src/webframeworks/nuxt.ts 15.27% 61 Missing ⚠️
packages/init/src/test/port.ts 0.00% 10 Missing ⚠️
Files with missing lines Coverage Δ
packages/init/src/const.ts 100.00% <100.00%> (ø)
packages/init/src/webframeworks/mod.ts 100.00% <100.00%> (ø)
packages/nuxt/src/runtime/server/lib.ts 100.00% <100.00%> (ø)
packages/nuxt/src/runtime/server/logic.ts 100.00% <100.00%> (ø)
packages/init/src/test/port.ts 9.60% <0.00%> (-0.84%) ⬇️
packages/init/src/webframeworks/nuxt.ts 15.27% <15.27%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Use @fedify/fixture instead of node:test in mod.test.ts
- Type event parameter as H3Event instead of unknown in middleware.ts

Co-Authored-By: Claude (claude-opus-4-20250514)
Move NOT_ACCEPTABLE_BODY and DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY into
a shared lib.ts to avoid string duplication across logic.ts and
plugin.ts.

Co-Authored-By: Claude (claude-opus-4-20250514)
- Close unclosed bash code fence in SKILL.md
- Fix "can not" to "cannot" in SKILL.md
- Use asterisk-wrapped file paths in README.md and integration.md

Co-Authored-By: Claude (claude-opus-4-20250514)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli CLI tools related component/federation Federation object related component/integration Web framework integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant