Major Changes
-
#14306
141c4a2Thanks @ematipico! - Changes the API for creating a customentrypoint, replacing thecreateExports()function with a direct export pattern.What should I do?
If you're using a custom
entryPointin your Cloudflare adapter config, update your existing worker file that usescreateExports()to reflect the new, simplified pattern:my-entry.ts
import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { handle } from '@astrojs/cloudflare/handler'; import { DurableObject } from 'cloudflare:workers'; class MyDurableObject extends DurableObject<Env> { constructor(ctx: DurableObjectState, env: Env) { super(ctx, env); } } export function createExports(manifest: SSRManifest) { const app = new App(manifest); return { default: { async fetch(request, env, ctx) { await env.MY_QUEUE.send('log'); return handle(manifest, app, request, env, ctx); }, async queue(batch, _env) { let messages = JSON.stringify(batch.messages); console.log(`consumed from our queue: ${messages}`); }, } satisfies ExportedHandler<Env>, MyDurableObject: MyDurableObject, }; }
To create the same custom
entrypointusing the updated API, export the following function instead:my-entry.ts
import { handle } from '@astrojs/cloudflare/utils/handler'; export default { async fetch(request, env, ctx) { await env.MY_QUEUE.send("log"); return handle(manifest, app, request, env, ctx); }, async queue(batch, _env) { let messages = JSON.stringify(batch.messages); console.log(`consumed from our queue: ${messages}`); } } satisfies ExportedHandler<Env>,
The manifest is now created internally by the adapter.
-
#14306
141c4a2Thanks @ematipico! - Development server now runs in workerdastro devnow runs your Cloudflare application using Cloudflare's workerd runtime instead of Node.js. This means your development environment is now a near-exact replica of your production environment—the same JavaScript engine, the same APIs, the same behavior. You'll catch issues during development that would have only appeared in production, and features like Durable Objects, Workers Analytics Engine, and R2 bindings work exactly as they do on Cloudflare's platform.To accommodate this major change to your development environment, this update includes breaking changes to
Astro.locals.runtime, removing some of its properties.What should I do?
Update occurrences of
Astro.locals.runtimeas shown below:Astro.locals.runtimeno longer contains theenvobject. Instead, import it directly:import { env } from 'cloudflare:workers';
Astro.locals.runtimeno longer contains thecfobject. Instead, access it directly from the request:Astro.request.cf;
Astro.locals.runtimeno longer contains thecachesobject. Instead, use the globalcachesobject directly:caches.default.put(request, response);
Astro.locals.runtimeobject is replaced withAstro.locals.cfContextwhich contains the CloudflareExecutionContext:const cfContext = Astro.locals.cfContext;
Minor Changes
-
#14306
141c4a2Thanks @ematipico! - Adds support forastro previewcommandDevelopers can now use
astro previewto test their Cloudflare Workers application locally before deploying. The preview runs using Cloudflare's workerd runtime, giving you a staging environment that matches production exactly—including support for KV namespaces, environment variables, and other Cloudflare-specific features.
Patch Changes
- Updated dependencies []:
- @astrojs/underscore-redirects@1.0.0