You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone!
I was experimenting with using remix vite setup for cloudflare workers app.
I thought people here might be interested and maybe have ideas for improvement, so please let me share.
I'm aware that remix team is planning to provide a better integration React Router Roadmap (view), but this approach might work reasonably okay for simple cases and it doesn't require any change on remix side.
The demo includes very simple example of KV integration. I wrote some details in the repository README, so feel free to take a look.
The general idea is probably same as what other vite-based frameworks do, which goes like:
for dev, frameworks rely on vite dev server as usual (which is nodejs, or maybe deno, bun), so server code doesn't have access to workerd runtime api for kv, etc.... But, users can setup necessary polyfills for nodejs using miniflare.
for build, frameworks bundle client and server code mostly as usual, but swaps out server entry to implement cloudflare workers module api (e.g. export default { fetch() { ... } }).
It's worth mentioning that, current non-vite remix's approach of local development for cloudflare workers (namely this template) actually makes use of wrangler dev, which provides a genuine workerd runtime already during development, which is important in terms of dev/build consistency.
However, wrangler dev-based local testing is still possible using local build (I included playwright e2e testing to demonstrate this in my repository), so this trade-off might be acceptable.
I would love to hear what others think!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
I was experimenting with using remix vite setup for cloudflare workers app.
I thought people here might be interested and maybe have ideas for improvement, so please let me share.
I'm aware that remix team is planning to provide a better integration React Router Roadmap (view), but this approach might work reasonably okay for simple cases and it doesn't require any change on remix side.
The repository and the demo application are here:
The demo includes very simple example of KV integration. I wrote some details in the repository README, so feel free to take a look.
The general idea is probably same as what other vite-based frameworks do, which goes like:
export default { fetch() { ... } }
).What's interesting is that recently miniflare v3 became easier to integrate for this purpose outside of wrangler cli.
For example, hono's dev server uses this approach to simulate workerd runtime https://github.com/honojs/vite-plugins/blob/60fef034b3ba4aeca9b21f91149d58a328d9f653/packages/dev-server/src/cloudflare-pages/cloudflare-pages.ts#L24-L28.
It's worth mentioning that, current non-vite remix's approach of local development for cloudflare workers (namely this template) actually makes use of
wrangler dev
, which provides a genuine workerd runtime already during development, which is important in terms of dev/build consistency.However,
wrangler dev
-based local testing is still possible using local build (I included playwright e2e testing to demonstrate this in my repository), so this trade-off might be acceptable.I would love to hear what others think!
Beta Was this translation helpful? Give feedback.
All reactions