Skip to content

docs(ws): use zero-config crossws server plugin#1427

Merged
pi0 merged 1 commit into
mainfrom
feat/ez-ws
Jul 3, 2026
Merged

docs(ws): use zero-config crossws server plugin#1427
pi0 merged 1 commit into
mainfrom
feat/ez-ws

Conversation

@pi0x

@pi0x pi0x commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

crossws#200 makes the server plugin's resolve optional — it now defaults to calling the app's fetch handler and reading the hooks that defineWebSocketHandler() attaches as .crossws. That makes the resolve: (req) => (await app.fetch(req)).crossws boilerplate in our docs redundant (it was h3 wiring itself back into itself).

This PR updates the WebSocket guide + example to the zero-config form:

 serve(app, {
-  plugins: [ws({ resolve: async (req) => (await app.fetch(req)).crossws })],
+  plugins: [ws()],
 });

Docs-only — no src/ changes. serve() already passes fetch: app.fetch to srvx and defineWebSocketHandler already attaches .crossws, so nothing in the framework needs to change.

Changes

  • docs/1.guide/901.advanced/2.websocket.md — use ws(), update prose, add a NOTE explaining resolve is now only for custom hook resolution, and drop the outdated "WIP" callout.
  • examples/websocket.mjs — drop the resolve argument.

Follow-up (not in this PR)

  • Bump the crossws peer/dev range once the release carrying crossws#200 is published (currently ^0.4.8).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified WebSocket setup instructions for H3 with CrossWS.
    • Updated examples to use a simpler plugin setup and noted when custom route resolution is needed.
  • Bug Fixes
    • Removed outdated wording about WebSocket support status, making the guidance clearer and more accurate.

crossws now defaults `resolve` to the app's `fetch` handler and reads the
hooks attached by `defineWebSocketHandler()`, so the manual
`resolve: (req) => (await app.fetch(req)).crossws` boilerplate is no longer
needed. Update the WebSocket guide and example to `ws()`, document when a
custom `resolve` is still useful, and drop the outdated "WIP" callout.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@pi0x
pi0x requested a review from pi0 as a code owner July 3, 2026 09:43
@coderabbitai

coderabbitai Bot commented Jul 3, 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: ef2af3b0-4a74-4467-bf4d-1ad5cba1b60d

📥 Commits

Reviewing files that changed from the base of the PR and between dae12fe and 0ddf326.

📒 Files selected for processing (2)
  • docs/1.guide/901.advanced/2.websocket.md
  • examples/websocket.mjs

📝 Walkthrough

Walkthrough

Documentation and example code for WebSocket usage with CrossWS were updated to replace explicit resolve callback configuration with the simplified ws() default plugin invocation, removing the prior "WIP" notice and clarifying when a custom resolver is still needed.

Changes

WebSocket Plugin Usage Simplification

Layer / File(s) Summary
Documentation updates
docs/1.guide/901.advanced/2.websocket.md
Replaces the "built-in support...WIP" notice with instructions to register CrossWS as a serve plugin, updates usage and full example snippets to use plugins: [ws()], and adds a note about when a custom resolve is needed.
Example code update
examples/websocket.mjs
Updates the serve plugin configuration to use ws() instead of ws({ resolve: ... }).

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A resolver once so wordy and long,
Now hums along with a simpler song,
ws() alone does the trick, it's true,
Hop, hop, hooray for less code to chew! 🐇✨

🚥 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 reflects the docs/example shift to zero-config CrossWS server plugin usage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ez-ws

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.

@pi0
pi0 merged commit 7df7abb into main Jul 3, 2026
9 checks passed
@pi0
pi0 deleted the feat/ez-ws branch July 3, 2026 11:12
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