Open
Description
Describe the bug
Cloudflare now recommends Workers over Pages and their March 2025 SDK for Cloudflare Workers renamed the execution context for Workers to platform.ctx
.
The latest npm create cloudflare@latest -- --framework=svelte
command generates an app.d.ts
file that defines platform.ctx: ExecutionContext
within App.Platform
.
// Relevant part of app.d.ts generated by create-cloudflare
declare global {
namespace App {
interface Platform {
env: Env;
cf: CfProperties;
ctx: ExecutionContext; // <-- Uses ctx & not context found within Cloudflare Pages
}
}
}
@sveltejs/adapter-cloudflarestill exposes **only**
platform.context`:
const platform = {
// …
context: proxy.ctx // old name
};
Result: event.platform.ctx
is undefined
; fresh projects fail at runtime and in typescript checks.
Many solutions but need Sveltekit & Cloudflare to be in consensus
Could provide both properties so the same code runs on:
- Workers (
ctx
is canonical) - Pages Functions / legacy Workers (
context
)
Proposed fix
Alias the field in runtime & emulator:
const platform = {
env: proxy.env,
cf: proxy.cf,
caches: proxy.caches,
ctx: proxy.ctx,
context: proxy.ctx // temporary alias
};
Reproduction
npm create cloudflare@latest -- my-svelte-app --framework=svelte
generates src/app.d.ts
with
// app.d.ts
interface Platform {
env: Env;
cf: CfProperties;
ctx: ExecutionContext; // ctx not context
}
System Info
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M2
Memory: 212.58 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.6.1 - /usr/local/bin/node
npm: 11.1.0 - /usr/local/bin/npm
bun: 1.2.15 - ~/.bun/bin/bun
Browsers:
Brave Browser: 137.1.79.118
Chrome: 136.0.7103.114
Safari: 18.5
Severity
annoyance