- Nuxt DevTools is connected
+ Connected to Vite DevTools RPC
+ Server says: {{ result }}
+
+
The current app is using
- vue@{{ client.host.nuxt.vueApp.version }}
+ vue@{{ host.nuxt.vueApp.version }}
Close DevTools
@@ -53,7 +64,7 @@ onDevtoolsClientConnected((client) => {
- Failed to connect to the client. Did you open this page inside Nuxt DevTools?
+ Connecting to Vite DevTools…
diff --git a/playgrounds/module-starter/package.json b/playgrounds/module-starter/package.json
index 7acb65d1f2..7066abcde5 100644
--- a/playgrounds/module-starter/package.json
+++ b/playgrounds/module-starter/package.json
@@ -25,6 +25,7 @@
},
"dependencies": {
"@nuxt/devtools-kit": "workspace:*",
+ "@vitejs/devtools-kit": "catalog:types",
"sirv": "catalog:prod"
},
"devDependencies": {
diff --git a/playgrounds/module-starter/playground/nuxt.config.ts b/playgrounds/module-starter/playground/nuxt.config.ts
index 83c7cdfe57..1082fb43e5 100644
--- a/playgrounds/module-starter/playground/nuxt.config.ts
+++ b/playgrounds/module-starter/playground/nuxt.config.ts
@@ -1,7 +1,8 @@
-import { startSubprocess } from '@nuxt/devtools-kit'
+import { onDevtoolsReady } from '@nuxt/devtools-kit'
import { createResolver, defineNuxtModule } from 'nuxt/kit'
const resolver = createResolver(import.meta.url)
+const devtoolsModule = process.env.NUXT_DEVTOOLS_LOCAL ? '../../../local' : '@nuxt/devtools'
export default defineNuxtConfig({
modules: [
@@ -9,7 +10,7 @@ export default defineNuxtConfig({
* My module
*/
'../src/module',
- '../../../local',
+ devtoolsModule,
/**
* Start a sub Nuxt Server for developing the client
*
@@ -20,18 +21,19 @@ export default defineNuxtConfig({
if (!nuxt.options.dev || nuxt.options.test)
return
- const _process = startSubprocess(
- {
- command: 'npx',
- args: ['nuxi', 'dev', '--port', '3300'],
- cwd: resolver.resolve('../client'),
- },
- {
- id: 'my-module:client',
- name: 'My Module Client Dev',
- },
- nuxt,
- )
+ onDevtoolsReady((ctx) => {
+ ctx.terminals.startChildProcess(
+ {
+ command: 'npx',
+ args: ['nuxi', 'dev', '--port', '3300'],
+ cwd: resolver.resolve('../client'),
+ },
+ {
+ id: 'my-module:client',
+ title: 'My Module Client Dev',
+ },
+ )
+ })
},
}),
],
diff --git a/playgrounds/module-starter/src/devtools.ts b/playgrounds/module-starter/src/devtools.ts
index 64323e2840..91096ea77e 100644
--- a/playgrounds/module-starter/src/devtools.ts
+++ b/playgrounds/module-starter/src/devtools.ts
@@ -1,6 +1,7 @@
import type { Resolver } from '@nuxt/kit'
import type { Nuxt } from 'nuxt/schema'
import { existsSync } from 'node:fs'
+import { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } from '@nuxt/devtools-kit'
const DEVTOOLS_UI_ROUTE = '/__my-module'
const DEVTOOLS_UI_LOCAL_PORT = 3300
@@ -33,19 +34,19 @@ export function setupDevToolsUI(nuxt: Nuxt, resolver: Resolver) {
})
}
- nuxt.hook('devtools:customTabs', (tabs) => {
- tabs.push({
+ onDevtoolsReady((ctx) => {
+ ctx.docks.register({
// unique identifier
- name: 'my-module',
- // title to display in the tab
+ id: 'my-module',
+ // title to display in the dock
title: 'My Module',
// any icon from Iconify, or a URL to an image
icon: 'carbon:apps',
// iframe view
- view: {
- type: 'iframe',
- src: DEVTOOLS_UI_ROUTE,
- },
+ type: 'iframe',
+ url: DEVTOOLS_UI_ROUTE,
+ // show it inside the `Nuxt` group, next to the built-in tabs
+ groupId: NUXT_DEVTOOLS_GROUP_ID,
})
})
}
diff --git a/playgrounds/module-starter/src/module.ts b/playgrounds/module-starter/src/module.ts
index 4d1a0c0bae..e156de4ec6 100644
--- a/playgrounds/module-starter/src/module.ts
+++ b/playgrounds/module-starter/src/module.ts
@@ -1,5 +1,4 @@
-import type { ClientFunctions, ServerFunctions } from '../types'
-import { extendServerRpc, onDevToolsInitialized } from '@nuxt/devtools-kit'
+import { onDevtoolsReady } from '@nuxt/devtools-kit'
import { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit'
import { setupDevToolsUI } from './devtools'
@@ -31,10 +30,16 @@ export default defineNuxtModule
({
if (options.devtools)
setupDevToolsUI(nuxt, resolver)
- onDevToolsInitialized(() => {
- const rpc = extendServerRpc('custom-rpc', {
- toUpperCase(t: string) {
- rpc.broadcast.greeting('world')
+ onDevtoolsReady((ctx) => {
+ // Everything registered through the scope is prefixed with `my-module:`
+ const { rpc } = ctx.scope('my-module')
+
+ rpc.register({
+ name: 'to-upper-case',
+ type: 'query',
+ handler(t: string) {
+ // call the client function registered by the iframe
+ rpc.broadcast({ method: 'greeting', args: ['world'], event: true })
return `${t.toUpperCase()} [from server]`
},
})
diff --git a/playgrounds/module-starter/types.ts b/playgrounds/module-starter/types.ts
deleted file mode 100644
index 6368bcd2a4..0000000000
--- a/playgrounds/module-starter/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export interface ServerFunctions {
- toUpperCase: (t: string) => string
-}
-
-export interface ClientFunctions {
- greeting: (t: string) => void
-}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b7a653b5a8..126dce20c0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -999,6 +999,9 @@ importers:
'@nuxt/kit':
specifier: npm:@nuxt/kit-nightly@5.0.0-2610052343-36eafab
version: '@nuxt/kit-nightly@5.0.0-2610052343-36eafab(@nuxt/schema-nightly@5.0.0-2610052343-36eafab)(confbox@0.2.4)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.2)(mlly@1.8.2)(oxc-parser@0.150.0)(rolldown@1.2.12)(unplugin@3.4.0(esbuild@0.28.2)(rolldown@1.2.12)(rollup@4.63.6)(vite@8.3.2)(webpack@5.111.1(cssnano@7.1.9(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.28)(svgo@4.1.0)))'
+ '@vitejs/devtools-kit':
+ specifier: ^0.7.6
+ version: 0.7.6(@devframes/agentic@1.1.0)(cac@7.0.0)(crossws@0.4.12(srvx@0.11.22))(ocache@0.3.0)(srvx@0.11.22)(vite@8.3.2)
sirv:
specifier: catalog:prod
version: 3.0.2
@@ -7833,7 +7836,6 @@ snapshots:
transitivePeerDependencies:
- crossws
- ocache
- optional: true
'@devframes/hub@1.2.0(@devframes/agentic@1.1.0)(crossws@0.4.12(srvx@1.0.5))(devframe@1.2.0)(ocache@0.3.0)':
dependencies:
@@ -8433,12 +8435,12 @@ snapshots:
confbox: 0.3.1
consola: 3.4.2
defu: 6.1.7
- exsolve: 1.1.1
+ exsolve: 1.1.3
fuzzysort: 4.0.2
get-port-please: 3.2.0
my-bad: 0.2.9(vite@8.3.2)
obug: 3.0.0
- package-manager-detector: 1.8.0
+ package-manager-detector: 1.9.0
pathe: 2.0.3
perfect-debounce: 2.1.0
pkg-types: 2.3.3
@@ -8468,7 +8470,7 @@ snapshots:
consola: 3.4.2
debug: 4.4.3(supports-color@10.2.2)
defu: 6.1.7
- exsolve: 1.1.1
+ exsolve: 1.1.3
fuse.js: 7.5.0
fzf: 0.5.2
giget: 3.3.1
@@ -10224,7 +10226,6 @@ snapshots:
- crossws
- ocache
- srvx
- optional: true
'@vitejs/devtools-kit@0.7.6(@devframes/agentic@1.1.0)(cac@7.0.0)(crossws@0.4.12(srvx@1.0.5))(ocache@0.3.0)(srvx@0.11.22)(vite@8.3.2)':
dependencies:
@@ -11137,7 +11138,6 @@ snapshots:
transitivePeerDependencies:
- ocache
- srvx
- optional: true
devframe@1.2.0(@devframes/agentic@1.1.0)(cac@7.0.0)(ocache@0.3.0)(srvx@1.0.5):
dependencies:
@@ -11953,7 +11953,6 @@ snapshots:
optionalDependencies:
crossws: 0.4.12(srvx@0.11.22)
ocache: 0.3.0
- optional: true
h3@2.0.1-rc.32(crossws@0.4.12(srvx@1.0.5))(ocache@0.3.0):
dependencies: