Thin wrapper for Cloudflare Workers KV
Requires Node.js 14 and up
npm install cloudflare-kv
or yarn add cloudflare-kv
CLOUDFLARE_ACCOUNT_ID=<Cloudflare-Account-Id>
CLOUDFLARE_TOKEN=<Cloudflare-API-Token>
CLOUDFLARE_NAMESPACE_ID=<Cloudflare-Workers-KV-Namespace-Id>
import CloudflareKV from "cloudflare-kv";
const kv = new CloudflareKV();
const CloudflareKV = require("cloudflare-kv");
const kv = new CloudflareKV({
accountId: "<Cloudflare-Account-Id>",
apiToken: "<Cloudflare-API-Token>",
namespaceId: "<Cloudflare-Workers-KV-Namespace-Id>",
});
await kv.put("key", { workers: "kv" });
const value = await kv.get("key");
// { workers: "kv" }
await kv.delete("key");
yarn
yarn test --watch
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.