From e6941da5b85211dc5f433961310d305c3ad57ad5 Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Wed, 6 Nov 2024 12:16:48 +0100 Subject: [PATCH 1/2] fix(cloudflare): use React 19's edge renderer for workers compatibility React 19 requires MessageChannel from node:worker_threads, which isn't available in Cloudflare's workerd runtime. Switch to React's edge-optimized server renderer to avoid MessageChannel dependency. --- packages/cloudflare/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloudflare/src/index.ts b/packages/cloudflare/src/index.ts index 4facef327..bd7366cbe 100644 --- a/packages/cloudflare/src/index.ts +++ b/packages/cloudflare/src/index.ts @@ -219,7 +219,7 @@ export default function createIntegration(args?: Options): AstroIntegration { const aliases = [ { find: 'react-dom/server', - replacement: 'react-dom/server.browser', + replacement: 'react-dom/server.edge', }, ]; From 86d1ac590c8df8886ccf76a941d4b7b794abfef3 Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Wed, 6 Nov 2024 12:52:29 +0100 Subject: [PATCH 2/2] Add changeset --- .changeset/chatty-eels-flow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chatty-eels-flow.md diff --git a/.changeset/chatty-eels-flow.md b/.changeset/chatty-eels-flow.md new file mode 100644 index 000000000..f97438041 --- /dev/null +++ b/.changeset/chatty-eels-flow.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': minor +--- + +Make Cloudflare adapter compatible with React 19 (useActionState, etc.) by switching to React's edge renderer for SSR