Allow custom worker script when deploying to Cloudflare
@teemingc is already working on this.
Since Jul 16, 2026.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
When deploying to Cloudflare there's no way to customize the worker. This means no Durable Objects, no RPC methods, no CRON jobs, just the fetch() handler.
Describe the proposed solution
Currently when building with the adapter-cloudflare the entry Worker file gets generated at .svelte-kit/cloudflare/_worker.js. At its core it just exports the fetch handler for the Worker.
// other stuff...
var worker_default = {
async fetch(req, env, context) {
// request handling...
}
};
export {
worker_default as default
};
Other frameworks like React Router create a workers folder in the root directory of the project containing app.ts—the worker script. It looks like this:
import { createRequestHandler } from "react-router";
declare module "react-router" {
export interface AppLoadContext {
cloudflare: {
env: Env;
ctx: ExecutionContext;
};
}
}
const requestHandler = createRequestHandler(
() => import("virtual:react-router/server-build"),
import.meta.env.MODE
);
export default {
async fetch(request, env, ctx) {
return requestHandler(request, {
cloudflare: { env, ctx },
});
},
} satisfies ExportedHandler<Env>;
React Router basically provides a handler you can use in your worker in the fetch(). Why wouldn't SvelteKit be able to provide something similar?
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.