Skip to content

Vite ​

@devframes/vite splits into @devframes/vite/single (dev-serve one devframe's SPA) and @devframes/vite/hub (mount a devframes-hub); the bare import throws.

single exports devframeVitePlugin, devframeViteBridge, and devframeVite; also used by @devframes/nuxt.

ts
import { devframeViteBridge, devframeVitePlugin } from '@devframes/vite/single'
import { defineConfig } from 'vite'
import devframe from './devframe'

export default defineConfig({
  // Statically mounts the built SPA at `/__<id>/` — no RPC server:
  plugins: [devframeVitePlugin(devframe)],
  // Or bridge the RPC/WS backend into this dev server instead — the
  // host app owns the SPA:
  // plugins: [devframeViteBridge(devframe)],
})

devframeVitePlugin — static mount ​

Mounts def.clientAssets at options.base (/__<id>/ default) with SPA fallback. clientAssets accepts a local directory or remote assets.

OptionDefaultDescription
basedef.basePath ?? '/__<id>/'Mount path.

devframeViteBridge — RPC bridge ​

Devframe spawns a separate RPC + WS server and registers Vite middleware at <base>__connection.json. To share Vite's port, pass its HTTP server to initDevframe / initHub via server.

OptionDefaultDescription
basedef.basePath ?? '/__<id>/'Mount path.
portshare Vite's HTTP serverPin a side-car RPC port instead.
hostdef.cli?.host ?? 'localhost'Bind host for a pinned side-car.
flags—To def.setup(ctx, { flags }).
authgated (interactive OTP)false to opt out, or a DevframeAuthHandler for a custom scheme.
mcpdef.cli?.mcptrue or McpRouteOptions to expose the MCP route at <base>__mcp.

devframeVite — convenience wrapper ​

devframeVite(def, { bridge, ...opts }) forwards to devframeViteBridge when bridge: true, else devframeVitePlugin; use them directly when a devframe needs both.

Mounting a hub ​

@devframes/vite/hub mounts a devframes-hub with viteDevframeHub(): wraps initHub, shares Vite's HTTP server, defaults dock UI to @devframes/hub-ui.

ts
import { viteDevframeHub } from '@devframes/vite/hub'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [viteDevframeHub({ devframes: [] })],
})

Pass ui to swap the viewer, ui: false for headless (via @devframes/vite/hub/client's mountDevframeHubClient()). Vite DevTools (@vitejs/devtools-kit) supports this natively; recommended once ({ quiet: true } to silence).

Released under the MIT License.