KV namespaces
A KV namespace is a key-value database replicated to Cloudflare’s global network.
Bind your KV namespaces through Wrangler or via the Cloudflare dashboard.
Bind your KV namespace through Wrangler
To bind KV namespaces to your Worker, assign an array of the below object to the kv_namespaces
key.
binding
string
- The binding name used to refer to the KV namespace.
id
string
- The ID of the KV namespace.
preview_id
string
- The ID of the KV namespace used during
wrangler dev
.
- The ID of the KV namespace used during
Example:
wrangler.tomlkv_namespaces = [ { binding = "<TEST_NAMESPACE>", id = "<TEST_ID>" }
]
Bind your KV namespace via the dashboard
To bind the namespace to your Worker in the Cloudflare dashboard:
- Log in to the Cloudflare dashboard.
- Go to Workers & Pages.
- Select your Worker.
- Select Settings > Variables.
- Go to KV Namespace Bindings.
- Select Add binding.