Skip to content

Add SvelteKit support to fedify init - #971

Open
Palcimer wants to merge 7 commits into
fedify-dev:mainfrom
Palcimer:issue-892-add-sveltekit-fedify-init
Open

Add SvelteKit support to fedify init#971
Palcimer wants to merge 7 commits into
fedify-dev:mainfrom
Palcimer:issue-892-add-sveltekit-fedify-init

Conversation

@Palcimer

Copy link
Copy Markdown
Contributor

Summary

Fedify already has a SvelteKit integration package and an example app, but fedify init command could not scaffold a SvelteKit project. Added a SvelteKit web framework option to @fedify/init.

Assisted-by: Claude Code:claude-sonnet-5

Related issue

Changes

  • Added webframeworks/sveltekit.ts which defines the WebFrameworkDescription and scaffolding command for SvelteKit.
  • Added a template file(hooks.server.ts) that integrates Fedify into a SvelteKit app.
  • Updated @fedify/init README.md and a tutorial document to include SvelteKit support.
  • Skipped the deno lookup test for SvelteKit, matching Astro, Nuxt and SolidStart, since Vite can't resolve @fedify/* packages that are only linked through Deno's local workspace links.

Benefits

  • Users can generate a SvelteKit app using fedify init.

Checklist

  • Did you add a changelog entry to the CHANGES.md?
  • Did you write some relevant docs about this change (if it's a new feature)?
  • [] Did you write a regression test to reproduce the bug (if it's a bug fix)?
  • [] Did you write some tests for this change (if it's a new feature)?
  • Did you run mise test on your machine?

Palcimer added 2 commits July 27, 2026 19:39
Fedify already ships a SvelteKit integration package and example app,
but `fedify init` couldn't scaffold one, so add a `sveltekit` option
via `sv create`.

fedify-dev#892

Assisted-by: Claude Code:claude-sonnet-5
@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

👷 Deploy Preview for fedify-json-schema processing.

Name Link
🔨 Latest commit df7e087
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a67359e19422c0008ff2e1f

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit 2ebf692
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a6d870c968aae000813cf3f

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

fedify init now supports SvelteKit project scaffolding, including package-manager commands, Fedify hook generation, registry wiring, test handling, dependency updates, and documentation.

Changes

SvelteKit init support

Layer / File(s) Summary
SvelteKit scaffolding and registration
packages/init/src/const.ts, packages/init/src/types.ts, packages/init/src/webframeworks/*, packages/init/src/templates/sveltekit/*, packages/init/src/json/*
Adds SvelteKit to the framework registry. It defines project creation commands, dependencies, tasks, and a Fedify hooks.server.ts integration.
Test and configuration handling
packages/init/src/test/*
Updates SvelteKit port replacement, records the unsupported Deno remote-package case, and adjusts import typing.
Documentation and release notes
packages/init/README.md, docs/tutorial/microblog.md, CHANGES.md, changes.d/init/sveltekit.md
Documents SvelteKit in supported options, the interactive prompt, and the release notes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FedifyInit
  participant SvelteKitCLI
  participant GeneratedApp
  User->>FedifyInit: Select SvelteKit and package manager
  FedifyInit->>SvelteKitCLI: Run the SvelteKit create command
  SvelteKitCLI->>GeneratedApp: Create the project
  FedifyInit->>GeneratedApp: Write the Fedify SvelteKit hook
Loading

Possibly related issues

Possibly related PRs

Suggested labels: component/cli, integration/sveltekit

Suggested reviewers: dahlia, sij411

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely states that SvelteKit support was added to fedify init.
Description check ✅ Passed The description accurately explains the SvelteKit scaffolding, template, documentation, and test updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.69014% with 13 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/sveltekit.ts 85.71% 3 Missing and 6 partials ⚠️
packages/init/src/test/port.ts 0.00% 4 Missing ⚠️
Files with missing lines Coverage Δ
packages/init/src/const.ts 100.00% <100.00%> (ø)
packages/init/src/test/lookup.ts 24.06% <100.00%> (+0.57%) ⬆️
packages/init/src/webframeworks/mod.ts 100.00% <100.00%> (ø)
packages/init/src/test/port.ts 14.28% <0.00%> (-0.25%) ⬇️
packages/init/src/webframeworks/sveltekit.ts 85.71% <85.71%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work! This PR can merge to main if you fix few points. First, please update the dependencies using mise run update-init-deps.

files: {
"src/hooks.server.ts": await readTemplate("sveltekit/hooks.server.ts"),
},
tasks: getNodeBunDevToolTasks(pm),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

vite does not inject environment variables from .env into process.env, which causes errors during testing using mysql. You can test it with mise test:init -w sveltekit -p pnpm -m mysql -k mysql --no-dry-run. Add dotenvx as a dependency and ensure that if the package manager is not Deno, the task is modified to dotenvx run -- <command>. For example, if dev: "vite dev" is automatically generated, it should be changed to dev: "dotenvx run -- vite dev".

@Palcimer
Palcimer force-pushed the issue-892-add-sveltekit-fedify-init branch from df7e087 to 68d5a9a Compare July 31, 2026 13:13
Palcimer added 4 commits July 31, 2026 22:23
Vite does not inject `.env` variables into `process.env`, so
non-Deno SvelteKit projects failed during `mise test:init` runs
that need KV/MQ connection settings (e.g. with `mysql`). Add
`@dotenvx/dotenvx` as a dev dependency and wrap the
`dev`/`build`/`preview` tasks with `dotenvx run --` for every
non-Deno package manager.

fedify-dev#892

Assisted-by: Claude Code:claude-sonnet-5
@Palcimer
Palcimer force-pushed the issue-892-add-sveltekit-fedify-init branch from d7e7c77 to 4f016f6 Compare July 31, 2026 13:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGES.md`:
- Line 180: Update the SvelteKit reference URL in the link definition from the
redirecting kit.svelte.dev address to https://svelte.dev/docs/kit, preserving
the existing SvelteKit link label and surrounding changelog content.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: aef9f463-1c54-4913-828b-756074eee2d8

📥 Commits

Reviewing files that changed from the base of the PR and between 4f016f6 and 60301b2.

📒 Files selected for processing (1)
  • CHANGES.md

Comment thread CHANGES.md Outdated
@Palcimer
Palcimer force-pushed the issue-892-add-sveltekit-fedify-init branch from 60301b2 to 2ebf692 Compare August 1, 2026 05:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/init/README.md`:
- Line 42: Update the SvelteKit link reference in the README to use the
SvelteKit documentation URL already established in CHANGES.md instead of the
generic Svelte homepage.

In `@packages/init/src/templates/sveltekit/hooks.server.ts.tpl`:
- Around line 1-7: Import $lib/logging in the generated hooks.server.ts template
before constructing the handle sequence, ensuring the logging configuration is
evaluated before fedifyHook(federation) runs. Keep the existing federation
import and handle composition unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e1f1dcd4-0184-483d-926d-5caa63c7a133

📥 Commits

Reviewing files that changed from the base of the PR and between 60301b2 and 2ebf692.

📒 Files selected for processing (15)
  • CHANGES.md
  • changes.d/init/sveltekit.md
  • docs/tutorial/microblog.md
  • packages/init/README.md
  • packages/init/src/const.ts
  • packages/init/src/json/deps.json
  • packages/init/src/json/kv.json
  • packages/init/src/json/mq.json
  • packages/init/src/templates/sveltekit/hooks.server.ts.tpl
  • packages/init/src/test/action.ts
  • packages/init/src/test/lookup.ts
  • packages/init/src/test/port.ts
  • packages/init/src/types.ts
  • packages/init/src/webframeworks/mod.ts
  • packages/init/src/webframeworks/sveltekit.ts

Comment thread packages/init/README.md
[Nitro]: https://nitro.build/
[Nuxt]: https://nuxt.com/
[SolidStart]: https://start.solidjs.com/
[SvelteKit]: https://svelte.dev/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Point the SvelteKit reference to the SvelteKit documentation.

The current reference opens the generic Svelte homepage. Use the SvelteKit documentation URL already used in CHANGES.md.

Proposed fix
-[SvelteKit]: https://svelte.dev/
+[SvelteKit]: https://svelte.dev/docs/kit
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/init/README.md` at line 42, Update the SvelteKit link reference in
the README to use the SvelteKit documentation URL already established in
CHANGES.md instead of the generic Svelte homepage.

Comment on lines +1 to +7
import { fedifyHook } from "@fedify/sveltekit";
import { sequence } from "@sveltejs/kit/hooks";
import federation from "$lib/federation";

export const handle = sequence(
fedifyHook(federation),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the SvelteKit server entry.
rg -n -C 3 'logging|federation|fedifyHook' \
  packages/init/src/templates/sveltekit/hooks.server.ts.tpl

# Locate and inspect the template that generates src/lib/federation.ts.
fd -t f -g 'federation.ts.tpl' packages/init/src/templates -x \
  rg -n -C 3 'logging|federation' {}

Repository: fedify-dev/fedify

Length of output: 892


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== target template =="
cat -n packages/init/src/templates/sveltekit/hooks.server.ts.tpl

echo
echo "== federation template(s) =="
fd -t f -g 'federation.ts.tpl' packages/init/src/templates -x sh -c 'printf "\n--- %s ---\n" "$1"; cat -n "$1"' sh {}

echo
echo "== generate hook and logging references =="
rg -n -C 4 'logging|src/lib/logging|hooks\.server|federation\.ts.tpl' packages/init/src

echo
echo "== static init flow snippets =="
fd -t f 'sveltekit\.ts|hooks\.server\.ts\.tpl|federation\.ts\.tpl' packages/init/src -x sh -c 'echo "--- $1 linecount ---"; wc -l "$1"' sh {}

Repository: fedify-dev/fedify

Length of output: 30074


Load LogTape in the SvelteKit server entry.

The generated src/lib/logging.ts is not imported by src/hooks.server.ts or the default src/lib/federation.ts, so the logging configuration is not evaluated. Import $lib/logging in packages/init/src/templates/sveltekit/hooks.server.ts.tpl before constructing handle.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/init/src/templates/sveltekit/hooks.server.ts.tpl` around lines 1 -
7, Import $lib/logging in the generated hooks.server.ts template before
constructing the handle sequence, ensuring the logging configuration is
evaluated before fedifyHook(federation) runs. Keep the existing federation
import and handle composition unchanged.

@Palcimer
Palcimer requested a review from 2chanhaeng August 1, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SvelteKit support to fedify init

3 participants