Skip to content

feat: add Fastify, SvelteKit, and Deno hub examples - #262

Merged
antfu merged 2 commits into
mainfrom
docs/add-runtime-examples
Aug 19, 2026
Merged

feat: add Fastify, SvelteKit, and Deno hub examples#262
antfu merged 2 commits into
mainfrom
docs/add-runtime-examples

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

What & why

Following up on the new handler / nodeMiddleware hub API (Hono, Nitro), this extends the hub-*-minimal family to more runtimes and mounting styles, so the set demonstrates that one initHub() instance is portable across framework-neutral hosts. Each example mounts the same hub and lets @devframes/hub-ui supply the viewer.

Examples added

  • hub-fastify-minimal — the nodeMiddleware host: hub.nodeMiddleware registered through @fastify/middie (the same (req, res, next) shape Vite's dev server consumes), with the RPC socket riding Fastify's own node:http server via hub.attach(server). No side-car port.
  • hub-sveltekit-minimal — a catch-all +server.ts (fallbackhub.handler(event.request)), with a side-car socket (ws: { sidecar: true }) since SvelteKit handlers never see upgrades. Exports trailingSlash = 'ignore' so the hub's trailing-slash URLs (standalone viewer + each frame SPA) are served verbatim instead of 308-redirected.
  • hub-deno-minimalDeno.serve delegating to hub.handler, with a same-origin fetch-upgrade socket.

Core change

  • New WebSocket transport devframe/rpc/transports/ws-deno (attachDenoWsTransport, crossws' Deno adapter), mirroring the existing ws-bun tier — crossws attaches the socket to the Response its handleUpgrade returns, so there's no separate websocket handler object. Registered in the package exports, tsdown entries, alias.tstsconfig.base.json paths, and knip config. tsnapi API snapshot added.

Docs

Added an examples page per host and updated the examples index table, the sidebar, and the hub-initiate shared-socket guide.

Notes

  • An Elysia example was scoped in but dropped: Elysia pulls exact-mirror@1.2.4, which pnpm's supply-chain trust policy flags as a trust downgrade; rather than weaken the guard, it was left out.
  • Verified locally: pnpm lint, pnpm knip, pnpm typecheck, pnpm test, pnpm build all green. Fastify smoke-tested end to end (HTTP, discovery, frame SPA, embedded.js, WS RPC round-trip); SvelteKit booted and its namespace verified over HTTP. Deno typechecks/builds — its runtime isn't installed in this environment, so it wasn't run live.

Created with the help of an agent.

Extend the hub-*-minimal family with three more runtimes and mounting
styles, each mounting the same initHub() instance:

- hub-fastify-minimal: hub.nodeMiddleware via @fastify/middie, with the RPC
  socket riding Fastify's own node:http server through hub.attach(server)
- hub-sveltekit-minimal: a catch-all +server.ts delegating to hub.handler,
  with a side-car socket (ws.sidecar) and trailingSlash: 'ignore' so the
  hub's trailing-slash URLs are served verbatim
- hub-deno-minimal: Deno.serve delegating to hub.handler, with a same-origin
  fetch-upgrade socket

Add the Deno WebSocket transport that the Deno example binds:
devframe/rpc/transports/ws-deno (attachDenoWsTransport, crossws' Deno
adapter), mirroring the existing ws-bun tier. Register it in the package
exports, tsdown entries, alias/tsconfig paths, and knip config.

Docs: add an examples page per host, and update the examples index, the
sidebar, and the hub-initiate socket guide to match.

Created with the help of an agent.
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 8c82a3b
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a850fe0e417610008716eee
😎 Deploy Preview https://deploy-preview-262--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 842fde0 into main Aug 19, 2026
12 checks passed
@antfu
antfu deleted the docs/add-runtime-examples branch August 19, 2026 02:09
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.

2 participants