Wrangler Publish erasing KV Namespace Binding

Every time I publish my worker the KV Namespace bind I defined previously is lost.

Is there a way to setup the wrangler.toml or any other way to maintain my KV bindings ?

I am a paid user.

Hey @byjg - this is a known bug with Wrangler, unfortunately. It’s a very high priority for the team, so I hope we have a fix out for you soon! You can track it on GitHub here: `wrangler deploy` un-does KV namespace bindings · Issue #92 · cloudflare/wrangler-legacy · GitHub

3 Likes

I had the same. The issue has been closed now, but I was not able to find the docs on the web, just in the PR diff. Add this to your Wrangler config:

kv-namespaces = [
  { binding: 'VARIABLE_NAME', id: 'namespaceid' }
]

it is there: