Is your feature request related to a problem?
Currently, Workers that export Durable Object classes cannot use Preview URLs. When using doQueue (the DOQueueHandler Durable Object for ISR revalidation deduplication) or doShardedTagCache (the DOShardedTagCache Durable Object), the OpenNext build bundles these DO classes into the main app Worker. This means the app Worker exports DO classes and is therefore ineligible for Cloudflare's preview URL feature.
Preview URLs are valuable for CI/CD workflows, PR previews, and staging environments, but are currently unavailable to any OpenNext app that uses DO-based queue or tag cache.
Describe the solution you'd like
Support an option (e.g., externalDurableObjects: true in open-next.config.ts or defineCloudflareConfig()) that separates the Durable Object classes (DOQueueHandler, DOShardedTagCache) into a dedicated standalone Worker during the build.
The main app Worker would reference the DOs via script_name in its wrangler config:
Since the app Worker would no longer export any DO classes, it would be eligible for preview URLs.
This pattern is already proven in the multi-worker setup, where the "server" Worker references DOs in the "middleware" Worker using script_name. The difference here is a simpler variant: a small DO-only Worker alongside the main app Worker, without the full middleware/server split.
Ideally, the @opennextjs/cloudflare build and deploy commands would:
- Generate a separate DO Worker with just the DO class exports and its own wrangler config (including migrations).
- Generate the main app Worker's wrangler config with
script_name references to the DO Worker.
- Deploy the DO Worker first, then the app Worker.
Describe alternatives you've considered
- Manual multi-worker setup: The existing multi-worker approach can work, but it explicitly states it is incompatible with preview URLs (because the middleware ingress Worker still exports the DOs). It also requires manual deployment orchestration and cannot use
@opennextjs/cloudflare deploy.
- Manually splitting the DO Worker: Users could manually create a separate Worker project for the DOs, but this requires understanding the build output paths, maintaining separate wrangler configs, and coordinating deployments — significant operational overhead.
- Avoiding DOs entirely: Using in-memory deduplication instead of
doQueue, but this loses cross-isolate deduplication and is less robust.
@opennextjs/cloudflare version
Latest
Additional context
Before submitting
Is your feature request related to a problem?
Currently, Workers that export Durable Object classes cannot use Preview URLs. When using
doQueue(theDOQueueHandlerDurable Object for ISR revalidation deduplication) ordoShardedTagCache(theDOShardedTagCacheDurable Object), the OpenNext build bundles these DO classes into the main app Worker. This means the app Worker exports DO classes and is therefore ineligible for Cloudflare's preview URL feature.Preview URLs are valuable for CI/CD workflows, PR previews, and staging environments, but are currently unavailable to any OpenNext app that uses DO-based queue or tag cache.
Describe the solution you'd like
Support an option (e.g.,
externalDurableObjects: trueinopen-next.config.tsordefineCloudflareConfig()) that separates the Durable Object classes (DOQueueHandler,DOShardedTagCache) into a dedicated standalone Worker during the build.The main app Worker would reference the DOs via
script_namein its wrangler config:Since the app Worker would no longer export any DO classes, it would be eligible for preview URLs.
This pattern is already proven in the multi-worker setup, where the "server" Worker references DOs in the "middleware" Worker using
script_name. The difference here is a simpler variant: a small DO-only Worker alongside the main app Worker, without the full middleware/server split.Ideally, the
@opennextjs/cloudflare buildanddeploycommands would:script_namereferences to the DO Worker.Describe alternatives you've considered
@opennextjs/cloudflare deploy.doQueue, but this loses cross-isolate deduplication and is less robust.@opennextjs/cloudflare version
Latest
Additional context
script_namedocs for external DO bindings: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objectsBefore submitting