Drivers
Vercel
Vercel KV
Store data in a Vercel KV Store.
Usage
Driver name: vercel-kv
Please check Vercel KV Limits.
import { createStorage } from "unstorage";
import vercelKVDriver from "unstorage/drivers/vercel-kv";
const storage = createStorage({
driver: vercelKVDriver({
// url: "https://<your-project-slug>.kv.vercel-storage.com", // KV_REST_API_URL
// token: "<your secret token>", // KV_REST_API_TOKEN
// base: "test",
// env: "KV",
// ttl: 60, // in seconds
}),
});
To use, you will need to install @vercel/kv
dependency in your project:
{
"dependencies": {
"@vercel/kv": "latest"
}
}
Note: For driver options type support, you might need to install @upstash/redis
dev dependency as well.
Options:
url
: Rest API URL to use for connecting to your Vercel KV store. Default isKV_REST_API_URL
.token
: Rest API Token to use for connecting to your Vercel KV store. Default isKV_REST_API_TOKEN
.base
: optional Prefix to use for all keys. Can be used for namespacing.env
: optional Flag to customize environment variable prefix (Default isKV
). Set tofalse
to disable env inference forurl
andtoken
options.
See @upstash/redis for all available options.
Vercel Blob
Store data in a Vercel Blob Store.
Currently Vercel Blob stores all data with public access.
Usage
Driver name: vercel-blob
To use, you will need to install @vercel/blob
dependency in your project:
npm i @vercel/blob
import { createStorage } from "unstorage";
import vercelBlobDriver from "unstorage/drivers/vercel-blob";
const storage = createStorage({
driver: vercelBlobDriver({
access: "public", // Required! Beware that stored data is publicly accessible.
// token: "<your secret token>", // or set BLOB_READ_WRITE_TOKEN
// base: "unstorage",
// envPrefix: "BLOB",
}),
});
Options:
access
: Whether the blob should be publicly accessible. (required, must bepublic
)base
: Prefix to prepend to all keys. Can be used for namespacing.token
: Rest API token to use for connecting to your Vercel Blob store. If not provided, it will be read from the environment variableBLOB_READ_WRITE_TOKEN
.envPrefix
: Prefix to use for token environment variable name. Default isBLOB
(env name =BLOB_READ_WRITE_TOKEN
).