Skip to content

feat: add public getDevToolsClientContext() API#219

Merged
antfu merged 2 commits intomainfrom
antfu/kit-client-context-api
Mar 18, 2026
Merged

feat: add public getDevToolsClientContext() API#219
antfu merged 2 commits intomainfrom
antfu/kit-client-context-api

Conversation

@antfu
Copy link
Member

@antfu antfu commented Mar 18, 2026

Summary

Adds a new public getDevToolsClientContext() API that allows accessing the global DevTools client context from anywhere on the client side. The context is set automatically when DevTools initializes in both embedded and standalone modes, and returns undefined if not yet initialized.

This provides a convenient way to access the RPC client and shared state without always requiring async getDevToolsRpcClient() calls, complementing the existing RPC client API.

Changes

  • New packages/kit/src/client/context.ts module exports getDevToolsClientContext() function
  • Context automatically bound to globalThis in both embedded and standalone initialization paths
  • Comprehensive documentation added to VitePress docs and skill references
  • Full examples showing usage with RPC calls and shared state access

🤖 Generated with Claude Code

…text access

Adds a new public API to access the DevToolsClientContext globally from anywhere on the client side. The context is set automatically when DevTools initializes in embedded or standalone mode, and returns undefined if not yet initialized. This allows easier access to the RPC client and shared state without always requiring async getDevToolsRpcClient() calls.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@219

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@219

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@219

@vitejs/devtools-rpc

npm i https://pkg.pr.new/@vitejs/devtools-rpc@219

@vitejs/devtools-self-inspect

npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@219

commit: 6576f2a

@antfu antfu merged commit 6c4cdbe into main Mar 18, 2026
9 checks passed
@antfu antfu deleted the antfu/kit-client-context-api branch March 18, 2026 01:47
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.

1 participant