KV quickstart
Register KV, write a settings value, read it back, and verify the JSON response.
This guide creates one settings key. The write route stores a JSON value and the read route returns it through the same kv handle.
The examples use the local fs-lite driver so you can verify the app before choosing Cloudflare or Vercel.
Prompt
Set up @vitehub/kv in this app.
- Install @vitehub/kv
- Register hubKv(), @vitehub/kv/nitro, or @vitehub/kv/nuxt
- Configure kv.driver as fs-lite for local development
- Add routes that call kv.set('settings', value) and kv.get('settings')
- Return the stored value as JSON
Docs: /docs/vite/kv/quickstart, /docs/nitro/kv/quickstart, or /docs/nuxt/kv/quickstart
Install KV
pnpm add @vitehub/kv
Register the integration
Register the Nuxt module and choose the local driver:
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vitehub/kv/nuxt'],
kv: {
driver: 'fs-lite',
base: '.data/kv',
},
})
Write a value
Add a route that writes the value:
server/api/settings.put.ts
import { kv } from '@vitehub/kv'
export default defineEventHandler(async () => {
await kv.set('settings', { enabled: true })
return { ok: true }
})
Read the value
Add a route that reads it back:
server/api/settings.get.ts
import { kv } from '@vitehub/kv'
export default defineEventHandler(async () => {
return {
settings: await kv.get('settings'),
}
})
Verify the response
Write the value:
curl -X PUT http://localhost:3000/api/settings
Read it back:
curl http://localhost:3000/api/settings
Expected response:
{
"settings": {
"enabled": true
}
}
Hosted Providers
The route code stays the same when you switch providers. Change config and deployment environment only:
Next Steps
- Use Usage for key naming, prefixes, and common methods.
- Use Runtime API for exact config shapes.
- Use Troubleshooting if the runtime mount or provider credentials are missing.

