Skip to content

docs: add From Express.js to h3 migration guide#1412

Open
thisismairaj wants to merge 2 commits into
h3js:mainfrom
thisismairaj:docs/from-expressjs-to-h3-1240
Open

docs: add From Express.js to h3 migration guide#1412
thisismairaj wants to merge 2 commits into
h3js:mainfrom
thisismairaj:docs/from-expressjs-to-h3-1240

Conversation

@thisismairaj

@thisismairaj thisismairaj commented Jun 8, 2026

Copy link
Copy Markdown

Summary

  • Ports the "From Express.js to h3" migration guide to v2 docs (closes Port From Express.js to h3 to v2 docs #1240)
  • Covers Hello World, routing, URL params, query string, request body, cookies, middleware, sub-apps, and error handling
  • Adds a compatibility table mapping Express features to their h3 v2 equivalents
  • Added new page link to the examples index (docs/4.examples/0.index.md)

Changes

  • docs/4.examples/from-expressjs-to-h3.md — new migration guide
  • docs/4.examples/0.index.md — added link to new page

Test plan

  • Docs build passes
  • All code examples use the v2 API (new H3(), serve(), utility imports from h3)
  • No references to removed v1 APIs (createApp, createRouter, fromNodeMiddleware)

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive migration guide from Express.js to h3 v2 covering routing, middleware lifecycle, request/response handling, URL validation, query strings, cookie management, nested routers, and error handling.
    • Added a new “From Express.js to h3” entry to the Examples list for easy discovery.

@thisismairaj thisismairaj requested a review from pi0 as a code owner June 8, 2026 07:21
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2bf10cd-47fe-41cd-84b4-5af993d696e8

📥 Commits

Reviewing files that changed from the base of the PR and between a4e246a and f82bede.

📒 Files selected for processing (1)
  • docs/4.examples/from-expressjs-to-h3.md
✅ Files skipped from review due to trivial changes (1)
  • docs/4.examples/from-expressjs-to-h3.md

📝 Walkthrough

Walkthrough

Restores the Express.js → h3 v2 migration guide and adds an examples index link; the guide covers setup, routing, params, query/body handling, cookies, lifecycle hooks, nested apps, error handling, and unavailable Express features.

Changes

Express.js to h3 v2 Migration Guide

Layer / File(s) Summary
Index link and Hello World setup
docs/4.examples/0.index.md, docs/4.examples/from-expressjs-to-h3.md
Examples index updated with a link to the migration guide. The guide opens with a Hello World example replacing Express express() and app.listen() with h3's new H3() and handler return values passed to serve().
Core request handling: routing, parameters, query, and body
docs/4.examples/from-expressjs-to-h3.md
Routing examples convert Express handlers using res.json() to h3 chained routes returning plain objects. Shows getRouterParam/getRouterParams, getValidatedRouterParams (with Zod), getQuery(event) for query strings, and readBody(event) for request bodies.
Advanced patterns: cookies, middleware, routing, and error handling
docs/4.examples/from-expressjs-to-h3.md
Cookie handling replaced by getCookie()/setCookie(). Middleware via app.use() replaced by lifecycle hooks onRequest/onResponse. Sub-app routing uses app.mount(prefix, subApp). Error handling via throwing HTTPError and onError hook.
Features not available and limitations
docs/4.examples/from-expressjs-to-h3.md
A table lists Express features unavailable in h3 v2 and notes that Express middleware requiring Node.js req/res objects cannot be used directly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • pi0

Poem

🐰 I hopped through docs with tiny paws,
Rewrote the routes without the flaws,
From res.send to returned delight,
Cookies, hooks, and params now bite-sized and bright,
thumps a happy foot and nibbles code carrots

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a migration guide from Express.js to h3. It directly matches the primary content of the PR.
Linked Issues check ✅ Passed The PR fully satisfies issue #1240 by porting the Express.js to h3 migration guide to v2 docs with Hello World, routing, params, query, body, cookies, middleware, sub-apps, and error handling using v2 APIs.
Out of Scope Changes check ✅ Passed All changes are directly in scope: a new migration guide file and an index update linking to it. No unrelated modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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 and usage tips.

Ports the v1 "From Express.js to h3" migration guide to v2, covering
Hello World, routing, URL params, query string, request body, cookies,
middleware (onRequest/onResponse hooks), sub-apps (app.mount), and
error handling (HTTPError). Includes a compatibility table of Express
features and their h3 v2 equivalents.

Closes h3js#1240
@thisismairaj thisismairaj force-pushed the docs/from-expressjs-to-h3-1240 branch from 661268b to a4e246a Compare June 8, 2026 07:23

@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 `@docs/4.examples/from-expressjs-to-h3.md`:
- Around line 247-249: The onResponse example uses an incorrect Response
property; update the callback passed to onResponse so it references
response.status (not response.statusCode) when logging; locate the onResponse
usage and change the template to use `${response.status}` while keeping the rest
(event.req.method and event.url.pathname) intact so the log shows the HTTP
method, path and correct status value.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6efe3701-0525-49d5-b962-4c215fdedb93

📥 Commits

Reviewing files that changed from the base of the PR and between 7eb018e and 661268b.

📒 Files selected for processing (2)
  • docs/4.examples/0.index.md
  • docs/4.examples/from-expressjs-to-h3.md

Comment thread docs/4.examples/from-expressjs-to-h3.md

@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.

♻️ Duplicate comments (1)
docs/4.examples/from-expressjs-to-h3.md (1)

247-249: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use response.status in the onResponse example (Line 248).

onResponse receives a Fetch Response; using response.statusCode is inaccurate in this snippet and may confuse migrations.

Suggested doc fix
   .use(onResponse((response, event) => {
-    console.log(`[${event.req.method}] ${event.url.pathname} -> ${response.statusCode}`);
+    console.log(`[${event.req.method}] ${event.url.pathname} -> ${response.status}`);
   }));
🤖 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 `@docs/4.examples/from-expressjs-to-h3.md` around lines 247 - 249, The example
in the onResponse handler uses an incorrect property response.statusCode; update
the snippet to use the Fetch Response API property response.status instead.
Locate the onResponse usage (the function receiving (response, event)) and
replace any references to response.statusCode with response.status so the log
line (which also references event.req.method and event.url.pathname) correctly
reports the HTTP status from the Fetch Response.
🤖 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.

Duplicate comments:
In `@docs/4.examples/from-expressjs-to-h3.md`:
- Around line 247-249: The example in the onResponse handler uses an incorrect
property response.statusCode; update the snippet to use the Fetch Response API
property response.status instead. Locate the onResponse usage (the function
receiving (response, event)) and replace any references to response.statusCode
with response.status so the log line (which also references event.req.method and
event.url.pathname) correctly reports the HTTP status from the Fetch Response.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d93bf82b-2e1d-4d07-a2d2-9f117f8b4feb

📥 Commits

Reviewing files that changed from the base of the PR and between 661268b and a4e246a.

📒 Files selected for processing (2)
  • docs/4.examples/0.index.md
  • docs/4.examples/from-expressjs-to-h3.md
✅ Files skipped from review due to trivial changes (1)
  • docs/4.examples/0.index.md

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.

Port From Express.js to h3 to v2 docs

1 participant