Skip to main content

Cloudflare Workers KV

Create a global, low-latency, key-value data storage.

Available on Free and Paid plans

Workers KV is a data storage that allows you to store and retrieve data globally. With Workers KV, you can build dynamic and performant APIs and websites that support high read volumes with low latency.

For example, you can use Workers KV for:

  • Caching API responses.
  • Storing user configurations / preferences.
  • Storing user authentication details.

Access your Workers KV namespace from Cloudflare Workers using Workers Bindings or from your external application using the REST API:

Workers Binding APIREST API

index.tswrangler.jsonc

export default {
	async fetch(request, env, ctx): Promise<Response> {
		// write a key-value pair
		await env.KV.put('KEY', 'VALUE');

		// read a key-value pair
		const value = await env.KV.get('KEY');

		// list all key-value pairs
		const allKeys = await env.KV.list();

		// delete a key-value pair
		await env.KV.delete('KEY');

		// return a Workers response
		return new Response(
			JSON.stringify({
				value: value,
				allKeys: allKeys,
			}),
		);
	},

} satisfies ExportedHandler<{ KV: KVNamespace }>;

See the full Workers KV binding API reference.

Get started


Features

Learn how Workers KV stores and retrieves data.

The Workers command-line interface, Wrangler, allows you to create, test, and deploy your Workers projects.

Bindings allow your Workers to interact with resources on the Cloudflare developer platform, including R2, Durable Objects, and D1.

Restrict a KV namespace to durably store data only within a specific jurisdiction to help meet compliance requirements.


Cloudflare R2 Storage allows developers to store large amounts of unstructured data without the costly egress bandwidth fees associated with typical cloud storage services.

Cloudflare Durable Objects allows developers to access scalable compute and permanent, consistent storage.

Built on SQLite, D1 is Cloudflare’s first queryable relational database. Create an entire database by importing data or defining your tables and writing your queries within a Worker or through the API.


More resources

Limits

Learn about KV limits.

Pricing

Learn about KV pricing.

Discord

Ask questions, show off what you are building, and discuss the platform with other developers.

Twitter

Learn about product announcements, new tutorials, and what is new in Cloudflare Developer Platform.