KV
Fast, globally distributed key-value database with infinite scale
Workers KV is an eventually consistent, high-performance key-value data database built for Workers. KV is ideal for read-heavy, low-latency edge decision making and configuration.
Global Low-Latency Reads
Infinite Scale, Simple API
More Than a Cache
Fast, global, simple - here's how:
Workers KV persists data in Cloudflare edge colocations and distributed central regions. Reads from new edge locations pull requested key-value pairs, making them available for sub-5ms reads on subsequent requests ("hot reads"). This architecture is optimized for read-heavy workloads, letting you scale to 1 million RPS and beyond, with no infrastructure to manage.
Build Distributed Configuration
Serve Static Assets
Personalize your app
Authorization
Manage Dynamic Data
Cloudflare Workers are fast, elastic, and serverless functions that scale automatically from zero to millions of requests
Instant access to the data your functions need. Workers KV stores and serves key-value pairs worldwide in milliseconds – ideal for personalization, configuration, and read-heavy workloads at global scale.
export default { async fetch(request, env, ctx): Promise<Response> { await env.KV.put('KEY', 'VALUE'); const value = await env.KV.get('KEY'); const allKeys = await env.KV.list(); await env.KV.delete('KEY');
return new Response( JSON.stringify({ value: value, allKeys: allKeys, }), ); },};export default { async fetch(request, env) { // Get the entire A/B test configuration object from KV const config = await env.CONFIG_STORE.get('homepage-test', 'json');
// Assign user to a group (e.g., based on a cookie or URL) const group = request.headers.get('X-User-Group') || 'control';
// Return the specific configuration for the user's group const variantData = config[group] || config.control; return new Response(JSON.stringify(variantData), { headers: { 'content-type': 'application/json' }, }); },} satisfies ExportedHandler<Env>;export default { async fetch(request, env) { // Get Authorization key from request headers const apiKey = request.headers.get('Authorization')?.replace('Bearer ', '');
if (!apiKey) { return new Response('Authorization header missing', { status: 401 }); }
// Check if the API key is valid and get associated metadata const keyData = await env.API_KEYS.get(apiKey, 'json');
if (keyData && keyData.enabled) { // Key is valid, add user info to the request and fetch the origin const newHeaders = new Headers(request.headers); newHeaders.set('X-User-ID', keyData.userId); return fetch(request, { headers: newHeaders }); }
return new Response('Invalid API Key', { status: 403 }); },} satisfies ExportedHandler<Env>;export default { async fetch(request, env) { const url = new URL(request.url); const path = url.pathname; // e.g., "/api/users"
// Look up the path prefix (e.g., "/api") to find the correct origin hostname const pathPrefix = '/' + path.split('/')[1]; const originHostname = await env.ROUTING_RULES.get(pathPrefix);
if (originHostname) { // Construct the new URL for the backend service const newUrl = new URL(url); newUrl.hostname = originHostname;
// Act as a reverse proxy: fetch the content from the backend // and return it to the original client. return fetch(newUrl.toString(), request); }
// If no route matches, return a 404 or forward to a default origin return new Response('Service not found for this path', { status: 404 }); },} satisfies ExportedHandler<Env>; Workers KV Pricing
Lightning-fast key-value storage. View Storage & Data pricing details
Stored Data
1 GB
$0.50 / GB-month
Read Requests
100,000 / day
$0.50 / million requests
Write, Delete, List requests
1,000 / day
$5.00 / million requests
Leagued
"
Choosing Cloudflare as our serverless provider was a no-brainer. Workers KV took just 15 minutes to get up and running. The ability to quickly spin up a Worker, deploy it to production, and scale effortlessly has been invaluable. "
Powerful primitives, seamlessly integrated
Built on systems powering 20% of the Internet, KV runs on the same infrastructure Cloudflare uses to build Cloudflare. Enterprise-grade reliability, security, and performance are standard.
Build without boundaries
Join thousands of developers who've eliminated infrastructure complexity and deployed globally with Cloudflare. Start building for free — no credit card required.