How to add KV binding to Qwik City project in local development?

I create my qwik city project with pnpm create cloudflare@latest, and I follow this instruction: https://developers.cloudflare.com/pages/framework-guides/deploy-a-qwik-site/#use-bindings-in-your-qwik-application my package.json:
{
"scripts": {
"pages:dev": "wrangler pages dev --kv=MY_KV -- pnpm run dev",
"dev": "vite --mode ssr"
}
}
{
"scripts": {
"pages:dev": "wrangler pages dev --kv=MY_KV -- pnpm run dev",
"dev": "vite --mode ssr"
}
}
$ pnpm pages:dev
$ pnpm pages:dev
// src/routes/index.tsx
export const useData = routeLoader$(({ platform }) => {
console.log((platform as (typeof platform & { MY_KV: KVNamespace })).MY_KV); // undefined
return [];
});
// src/routes/index.tsx
export const useData = routeLoader$(({ platform }) => {
console.log((platform as (typeof platform & { MY_KV: KVNamespace })).MY_KV); // undefined
return [];
});
The MY_KV is not in platform
2 Replies
mattp
mattpOP16mo ago
GitHub
[🐞] Cloudflare Pages: Ability to run cloudflare pages dev server wi...
Which component is affected? Qwik Rollup / Vite plugin Describe the bug The current Cloudflare pages setup makes it hard to develop qwik-city with Cloudflare page functions. Cloudflare has D1, KV e...
Want results from more Discord servers?
Add your server