Remix local dev with hot reload and resource binding
I'm using the remix template (vite compiler) to develop a pages project locally. I can't find how to add bindings to D1 or KV so I can simulate them locally with live reload support.
I read that
cloudflareDevProxyVitePlugin
set up some proxies for that but not sure how that works. Should I run both wrangler pages dev
and remix vite:dev
? Should I add some watch
command?
Any help will be appreciated. Thanks!1 Reply
Hey there, I've set this up quite recently. Let me show you the relevant files.
vite.config.ts
wrangler.toml
load-context.ts
(this file is pre-made when you use the Remix Cloudflare template). Simply modify the env type to include D1
And that's pretty much it tbh. Remember to setup the D1 binding for your pages project in production. In local dev everything should just work normally.
If you're unsure how to setup remix with Cloudflare, simply use
Sorry, I figured I should clarify to answer your question exactly. There is no extra setup needed. Remix and vite will automatically use wrangler + miniflare in the background to simulate local resources you have defined in wrangler.toml