Skip to content

abcfy2/astro-react-hydration-bug-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Astro React Hydration Bug — Minimal Reproduction

Vite optimizeDeps race condition causes createRoot not found in dev mode.

Bug

After pnpm dev, React island hydration fails:

[astro-island] Error hydrating /src/components/Counter.tsx
SyntaxError: The requested module 'react-dom/client.js'
does not provide an export named 'createRoot'

pnpm buildnode dist/server/entry.mjs is NOT affected.

Reproduce

git clean -fdx
pnpm i
pnpm dev
# Open http://localhost:4321/ in browser
# Console shows createRoot error

Root Cause

The built-in plugin astro:integration-container has a buildStart hook without applyToEnvironment filter, causing it to run in the client environment. The SSR-only route.js (from Actions onRequest) gets registered in the client depsOptimizer before React's optimizeDeps.include is processed. Vite's initial optimization produces only 1 entry (route.js), skipping react-dom/client. The browser receives the raw CJS file and cannot resolve the named export.

See GitHub #16387 for details.

Why paraglide + tailwindcss?

Four conditions are required: adapter + React + Actions + React island. But these four alone don't trigger the bug — Vite starts fast enough that optimizeDeps.include is processed before buildStart.

@inlang/paraglide-js (compiles inlang project at startup) and @tailwindcss/vite (Vite plugin pipeline) combined add enough startup overhead to shift the timing, causing buildStart to execute before optimizeDeps.include. Neither alone is sufficient.

Environment

  • Astro 6.3.3 / @astrojs/react 5.0.5 / Vite 7.3.3
  • @inlang/paraglide-js 2.18.0 / @tailwindcss/vite 4.3.0
  • React 19.2.6 / Node 24

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages