Skip to content
Go back

Migrating to Astro 5 with React 19 on Cloudflare Pages

Published:  at  02:42 AM

Astro + React + Cloudflare

I have successfully deployed Astro v4 sites to Cloudflare pages without much ado. Astro 5 continues to add new features for dynamic sites along with improved static site generation. React 19 introduces server components and improved performance. However, deploying on Cloudflare Pages requires some special considerations, particularly around React DOM.

Cloudflare Workaround for React DOM

When using React 19 with Astro on Cloudflare Pages, you’ll need to modify your astro.config.ts to handle the React DOM dependency. I got a MessageChannel is not defined error right at the last step before deploying:

Error: Failed to publish your Function. Got error: Uncaught ReferenceError: MessageChannel is not defined
  at renderers.mjs:6530:16 in requireReactDomServer_browser_production
  at renderers.mjs:12527:8 in requireServer_browser
  at renderers.mjs:12539:29

Fortunately the workaround is described at React 19 + Cloudflare Adapter -> “Bug: Uncaught ReferenceError: MessageChannel is not defined” · Issue #12824:

astro.conf.ts

Happy deploying!