safa
February 23, 2023, 11:37pm
1
I start my local pages development thus:
npx wrangler pages dev --kv=TEST -- npm start
But I want to seed kv TEST local namespace with a few values before my functions are called. Is there a way to do this with a local file (e.g. like .dev.vars) or with command line options on wrangler?
i40west
February 24, 2023, 3:03am
2
Local kv uses regular files in .wrangler/state/kv/<namespace>
. The name of the file is the key, and the content is the value.
So make a file in .wrangler/state/kv/TEST/foo
with content bar
, and Bob’s your uncle.
Looks like this may no longer be the case for miniflare/wrangler v3
The state file for KV seems to be a combination of files backed by a sqlite db
.wrangler/state/v3/kv/MY_KV/db.sqlite
.wrangler/state/v3/kv/MY_KV/db.sqlite-shm
.wrangler/state/v3/kv/MY_KV/db.sqlite-wal
.wrangler/state/v3/kv/MY_KV/blobs/d961e1711e48169b524c91b772c70bac04c4d358e6069db74207755b52eb40bc000011b97d875303