Skip to content

feat(devtools): client-side onDevtoolsReady + expose Vite DevTools client; fix client RPC registration#1023

Merged
antfu merged 4 commits into
nuxt:mainfrom
antfubot:feat/client-rpc-context
Jul 15, 2026
Merged

feat(devtools): client-side onDevtoolsReady + expose Vite DevTools client; fix client RPC registration#1023
antfu merged 4 commits into
nuxt:mainfrom
antfubot:feat/client-rpc-context

Conversation

@antfubot

@antfubot antfubot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

What & why

Follow-up to #1021, bringing the client-side RPC surface to parity with the server.

Client-side onDevtoolsReady()

Mirror of the server's onDevtoolsReady, exported from @nuxt/devtools-kit/iframe-client. Runs once the Vite DevTools client connects and hands back the DevToolsRpcClient — the recommended entry point for client-side integration:

import { onDevtoolsReady } from '@nuxt/devtools-kit/iframe-client'

onDevtoolsReady((kit) => {
  kit.client.register({ name: 'my-module:on-update', type: 'event', handler })
})

Expose the Vite DevTools client (symmetry with the server)

client.devtools.devtoolsKit is now the connected DevToolsRpcClient, mirroring nuxt.devtools.devtoolsKit on the server — full devframe-native access (register client RPC, call server functions, shared state, streaming, scoping) with no @vitejs/devtools-kit/client import needed.

Deprecate extendClientRpc

Deprecated in favour of onDevtoolsReady((kit) => kit.client.register(...)) (or the exposed devtoolsKit). Now also overrides by default via the forced upsert below.

Fix the DF0022 client RPC errors

The legacy client RPC proxy registered its event functions (refresh, callHook, onTerminalData, onTerminalExit, navigateTo) via a has() ? update() : register() dance that could throw DF0022: RPC function "…" is not registered. upsertClientFunction now force-registers (register(def, true)) — an idempotent override that never trips DF0021/DF0022 across (re)connect or overrides.

Notes

  • Client-only change.
  • pnpm lint, pnpm build, pnpm typecheck, and unit tests all pass.

This PR was created with the help of an agent.

…ndClientRpc

The legacy client RPC proxy registered its event functions (refresh, callHook,
onTerminalData, onTerminalExit, navigateTo) via a has()->update()/register()
dance that could throw DF0022 ("not registered"). Force-register instead so it
is an idempotent override, fixing the errors and making registration robust
across (re)connect and integration overrides.

`extendClientRpc` now overrides by default (via the forced upsert) and is
deprecated in favour of registering on the devframe client context
(`getDevToolsRpcClient()` / `getDevToolsClientContext()` from
`@vitejs/devtools-kit/client`).

Created with the help of an agent.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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: 3ebd59ef-24d4-4e79-8b2f-ef1510308e4a

📥 Commits

Reviewing files that changed from the base of the PR and between e6cf4bb and 3c41be3.

📒 Files selected for processing (1)
  • packages/devtools/client/composables/rpc.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/devtools/client/composables/rpc.ts

📝 Walkthrough

Walkthrough

The change exposes a connected devtoolsKit RPC client, documents it as the replacement for extendClientRpc, and adds deprecation documentation and a one-time runtime warning. Client RPC handler upserts now always use forced registration instead of conditional update-or-register logic.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: client-side onDevtoolsReady, exposing the DevTools client, and client RPC registration fixes.
Description check ✅ Passed The description is directly about the client-side RPC API, deprecation, and registration fixes introduced by the PR.
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 unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/devtools/client/composables/rpc.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

Mirror the server-side `nuxt.devtools.devtoolsKit` on the client: the injected
`client.devtools` now carries `devtoolsKit`, the connected Vite DevTools RPC
client, giving module authors full devframe-native access (register client RPC
functions, call server functions, shared state, streaming, scoping) without
importing from `@vitejs/devtools-kit/client` themselves.

`extendClientRpc`'s deprecation now points at
`client.devtools.devtoolsKit?.client.register(...)`.

Created with the help of an agent.
@antfubot antfubot changed the title fix(devtools): force-register client RPC functions + deprecate extendClientRpc feat(devtools): expose Vite DevTools client on NuxtDevtoolsClient; fix client RPC registration Jul 15, 2026
Mirror the server's `onDevtoolsReady` on the client: exported from
`@nuxt/devtools-kit/iframe-client`, it runs once the Vite DevTools client is
connected and hands back the `DevToolsRpcClient` (`client.devtools.devtoolsKit`),
the recommended entry point for client-side integration (register client RPC,
call server functions, shared state, streaming, ...).

`extendClientRpc`'s deprecation now points at this hook.

Created with the help of an agent.
@antfubot antfubot changed the title feat(devtools): expose Vite DevTools client on NuxtDevtoolsClient; fix client RPC registration feat(devtools): client-side onDevtoolsReady + expose Vite DevTools client; fix client RPC registration Jul 15, 2026
@antfu antfu merged commit 88c4f1c into nuxt:main Jul 15, 2026
6 of 7 checks passed
antfubot added a commit that referenced this pull request Jul 15, 2026
…n 00

Rebased feat/ecosystem-playgrounds onto main after #1021
(devframe-native hosts + nostics deprecation foundation) and
#1023 (client RPC registration fix) merged, and re-ran the full
dogfooding pass. No git conflicts during the rebase.

Findings added to REPORTS.md:
- The earlier DF0022 "RPC function not registered" console errors
  (refresh/callHook/onTerminalData/onTerminalExit/navigateTo) no longer
  reproduce — fixed by #1023.
- Plan 00's deprecation diagnostics are live and already flagging real
  ecosystem usage: NDT_DEP_0003 (extendServerRpc deprecated) fires from both
  @nuxt/fonts and nuxt-og-image's nuxtseo-shared dependency. NDT_DEP_0004
  (startSubprocess deprecated) fires from this repo's own local.ts dev
  helper, not from any ecosystem module.
- @nuxt/scripts's legacy addCustomTab still works but didn't trigger a
  matching deprecation diagnostic — flagged as a follow-up.

Everything else held: all three modules still load, all three tabs are
still reachable (still only via the SideNav overflow menu), builds still
succeed against both the stubbed and fully-built local @nuxt/devtools.

Co-authored-by: opencode <noreply@opencode.ai>
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