Cloudflare DevelopersCD
Cloudflare Developers3y ago
9 replies
sten

How do you write to Cloudflare KV when developing locally with wrangler dev?

I remember that you could write directly to Cloudflare KV's namespace when running wrangler dev locally.

name = "project_name"
main = "src/index.js"
compatibility_date = "2022-10-06"
type = "webpack"

account_id = "account_id..."
workers_dev = true

kv_namespaces = [
    { binding = "namespace_name", id = "id..." }
]

[env.staging]
kv_namespaces = [
    { binding = "namespace_name", id = "id..." }
]

[env.production]
kv_namespaces = [
    { binding = "namespace_name", id = "id..." }
]


This is what my wrangler.toml looks like.
I am currently running by calling wrangler dev.
I have logged in with wrangler. It was a while ago since I did this, maybe an update have come or so.
Right now it writes to local cache at .wrangler/kv
Was this page helpful?