# KV_DISABLED

<!-- Generated by docs/modules/diagnostics from the package catalogs. Write a guide in docs/diagnostics/<CODE>.md instead of editing this file. -->

A `kv` call, such as `kv.get()`, throws `KV_DISABLED`. The runtime has a KV config, but that config turns KV off, so no store exists.

## Why it happens

The `kv` helper reads the generated module `#vitehub/kv/config`. When that module exports `kv: false`, the first operation throws. The module exports `false` when:

- An app that uses `@vite-hub/kv` alone passes `false` to `hubKV()`.
- A Nuxt app uses the `vite-hub/nuxt` module without `kv`. The module then writes a KV config with `kv: false`, because the Console and Agents bundle the KV operations in every app.

The `kv.*` operations behind the Console KV section and the `vitehub kv` commands also report `KV_DISABLED` when the app has no KV store.

`KV_DISABLED` is a configuration error. It throws, and it does not come back as `[error, value]`.

## Fix it

```diff [nuxt.config.ts]
 export default defineNuxtConfig({
   modules: ['vite-hub/nuxt'],
-  vitehub: { host: 'node' },
+  vitehub: { host: 'node', kv: true },
 })
```

`kv: true` turns KV on with the default driver of the host. Pass an object to select a driver or add named stores.

```diff [vite.config.ts]
 export default defineConfig({
-  plugins: [vitehub({ host: 'node' })],
+  plugins: [vitehub({ host: 'node', kv: true })],
 })
```

In a Vite app, set `kv` in `vitehub()` the same way, or set a store config such as `kv: { driver: 'fs-lite' }`. With `@vite-hub/kv` alone, call `hubKV()` without `false`.

## Check the fix

Restart the dev server. Then run `vitehub kv list` from another terminal. It lists the keys of the default store and does not report `KV_DISABLED`. Call the route that uses `kv` to check the app code.

## Related

- [KV configuration](https://vitehub.dev/docs/kv/configure)
- [Enable KV](https://vitehub.dev/docs/kv/get-started#enable-kv)
- [KV limits and errors](https://vitehub.dev/docs/kv/limits-and-errors)
- [Read and write KV keys](https://vitehub.dev/docs/development/cli#read-and-write-kv-keys)
- [`KV_STORE_NOT_FOUND`](https://vitehub.dev/docs/kv/diagnostics/kv_store_not_found)
- [`KV_INVALID_CONFIG`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_config)

## Source

`KV_DISABLED` belongs to the `kv` package. Its catalog entry is in [`src/error-diagnostics.ts`](https://github.com/vite-hub/vitehub/blob/main/packages/kv/src/error-diagnostics.ts#L105). It is raised in [`src/runtime/driver.ts`](https://github.com/vite-hub/vitehub/blob/main/packages/kv/src/runtime/driver.ts#L123), [`src/runtime/hosted-storage.ts`](https://github.com/vite-hub/vitehub/blob/main/packages/kv/src/runtime/hosted-storage.ts#L31), [`src/runtime/operations.ts`](https://github.com/vite-hub/vitehub/blob/main/packages/kv/src/runtime/operations.ts#L166).

See [all KV diagnostics](https://vitehub.dev/docs/kv/diagnostics).

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/kv.md)
- [Get started](https://vitehub.dev/raw/docs/kv/get-started.md)
- [Configure](https://vitehub.dev/raw/docs/kv/configure.md)
- [Server API](https://vitehub.dev/raw/docs/kv/server-api.md)
- [Agent capability](https://vitehub.dev/raw/docs/kv/agent-capability.md)
- [Hosts](https://vitehub.dev/raw/docs/kv/hosts.md)
- [Limits and errors](https://vitehub.dev/raw/docs/kv/limits-and-errors.md)

Next: [KV_INVALID_BATCH](https://vitehub.dev/raw/docs/kv/diagnostics/kv_invalid_batch.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
