Vercel KV
Use the Vercel provider path when runtime KV should read and write through Upstash REST credentials.
Vercel needs the upstash driver and runtime environment variables. ViteHub masks build-time Upstash credentials in generated config and resolves the real values when the first KV operation runs.
Configure KV
Register the Vite plugin and set kv.driver to upstash:
import { defineConfig } from 'vite'
import { hubKv } from '@vitehub/kv/vite'
export default defineConfig({
plugins: [hubKv()],
kv: {
driver: 'upstash',
},
})
Add Runtime Environment Variables
Set the Upstash REST variables:
KV_REST_API_URL=https://example.upstash.io
KV_REST_API_TOKEN=<upstash-rest-token>
Let Hosting Select Upstash
When hosting resolves to Vercel and no explicit driver is set, ViteHub selects upstash automatically:
export default defineNitroConfig({
modules: ['@vitehub/kv/nitro'],
})
This still requires runtime credentials. If they are missing, the first KV access throws:
Missing runtime environment variable `KV_REST_API_URL` for Upstash KV.
Avoid fs-lite on Vercel
fs-lite is a local development driver. If Vercel hosting is detected while fs-lite is configured, the Nitro module logs:
Vercel hosting requires Upstash-backed KV. Set `KV_REST_API_URL` and `KV_REST_API_TOKEN`.
Change the driver to upstash or remove explicit local config before deploying.
Inline Credentials
You can pass credentials in config:
kv: {
driver: 'upstash',
url: process.env.KV_REST_API_URL,
token: process.env.KV_REST_API_TOKEN,
}
Environment variables are preferred for hosted deployments. They keep secrets in runtime configuration instead of source-controlled config files.
Verify the Provider
Write a value:
curl -X PUT https://<your-project>.vercel.app/api/settings
Read it back:
curl https://<your-project>.vercel.app/api/settings
Expected response:
{
"settings": {
"enabled": true
}
}
Common Failures
| Symptom | Cause | Fix |
|---|---|---|
Missing runtime environment variable \KV_REST_API_URL`` | Upstash URL is missing at runtime. | Set KV_REST_API_URL. |
Missing runtime environment variable \KV_REST_API_TOKEN`` | Upstash token is missing at runtime. | Set KV_REST_API_TOKEN. |
Vercel logs warn about fs-lite | Explicit local driver was deployed. | Set kv.driver to upstash or rely on Vercel hosting inference. |

