ViteHub is still experimental. Expect bugs and breaking changes.

Runtime Helpers and stable imports

Learn how application code calls ViteHub primitives without importing generated internals.

A Runtime Helper is a runtime API used by application code to call, inspect, or use a configured ViteHub primitive. Stable ViteHub import paths keep application code independent from Provider Output, virtual modules, and generated file locations.

Why it exists

Generated output changes with provider, host, package options, and deployment target. Server code should not need those details to call KV, read a Workspace, run an Agent, or access Server Env.

Stable imports also make docs and agent instructions actionable. An agent can search for one documented import instead of guessing provider-specific modules.

Examples

Use a package Runtime Helper from server code.

server/api/settings.get.ts
import { kv } from '@vite-hub/kv'

export default defineEventHandler(async () => {
  return {
    settings: await kv.get('settings'),
  }
})

Use a generated stable import only when the package documents it.

server/secrets.ts
import { useServerEnv } from '#vitehub/env/server'

export function getGithubToken() {
  return useServerEnv().github.token.unseal()
}

Run an Agent through the Agent Package instead of calling generated route code.

server/api/support.post.ts
import { runAgent } from '@vite-hub/agent'
import support from '../agents/support'

export default defineEventHandler(async (event) => {
  return runAgent(support, { runtime: 'vite' }, await readBody(event))
})

When to use what

SurfaceUse it from app code?Why
Package Runtime HelperYesIt is the stable public runtime API.
#vitehub/... stable generated importYes, when documentedIt hides generated file paths behind a ViteHub-owned import.
Framework virtual moduleNo, unless documentedIt exposes integration detail.
Raw .vitehub file pathNoIt is Provider Output or generated backing state.
Provider SDK or bindingOnly inside provider-specific codeIt bypasses the ViteHub primitive boundary.

Inspect it

Search for imports from @vite-hub/*, @vite-hub/*/vite, and documented #vitehub/... paths. Those imports show where the public boundary is.

Next steps

Copyright © 2026