Unable to use Cloudflare's Durable Objects with Remix when using Cloudflare Pages #3066
Replies: 3 comments 11 replies
-
You can define your own worker in the functions/ directory, I think it needs to be in a subfolder though. |
Beta Was this translation helpful? Give feedback.
-
Another reason for Remix to use
Right now, it seems our only option to deploy a Remix app from a monorepo to Cloudflare Pages using GitHub Actions is to write our own JS workflow. Granted, improvements to Cloudflare Pages would resolve this; but so would Remix using |
Beta Was this translation helpful? Give feedback.
-
Has anything changed, especially with vite now? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently the only way to use Durable Objects when using Cloudflare Pages is by having a completely separate Worker and communicating with it from Remix.
This is because there is no way to
export
the Durable Objectclass
from a Pages Function.However, this can be done in Advanced Mode.
Since Remix takes over all paths anyways (i.e.
functions/[[path]].js
), why not use_worker.js
instead? This would allow the user to modify it at the top level which is more what I would have expected from using Pages with Remix anyways.There is a (somewhat hacky) workaround.
This works, but it's not the cleanest implementation.
I think Remix should provide a handler for Pages Functions in "Advanced" mode rather than the simple mode. This would allow you to do more advanced things like working with Durable Objects, etc.
Beta Was this translation helpful? Give feedback.
All reactions