Skip to content

Conversation

@harlan-zw
Copy link
Collaborator

After investigating a "thin wrapper" approach around React 19's native metadata utilities, determined this is not viable due to:

  • No programmatic API for third-party libraries
  • preinit/preload only work for scripts/stylesheets
  • No hooks to control metadata hoisting
  • No body tag positioning support

Instead, implemented streaming SSR similar to Vue's approach:

  • Add renderReactStream() utility for streaming with head injection
  • Create vite-ssr-react-streaming example demonstrating usage
  • Buffers initial chunks to detect Suspense boundaries
  • Injects head tags into first chunk before streaming
  • Maintains all advanced unhead features (ordering, positioning, etc.)

Benefits:

  • Fast TTFB with streaming
  • Full Suspense support
  • All unhead features maintained
  • SEO-friendly
  • Backward compatible

See REACT_STREAMING_IMPLEMENTATION.md for full details and rationale.

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

After investigating a "thin wrapper" approach around React 19's native
metadata utilities, determined this is not viable due to:
- No programmatic API for third-party libraries
- preinit/preload only work for scripts/stylesheets
- No hooks to control metadata hoisting
- No body tag positioning support

Instead, implemented streaming SSR similar to Vue's approach:

- Add renderReactStream() utility for streaming with head injection
- Create vite-ssr-react-streaming example demonstrating usage
- Buffers initial chunks to detect Suspense boundaries
- Injects head tags into first chunk before streaming
- Maintains all advanced unhead features (ordering, positioning, etc.)

Benefits:
- Fast TTFB with streaming
- Full Suspense support
- All unhead features maintained
- SEO-friendly
- Backward compatible

See REACT_STREAMING_IMPLEMENTATION.md for full details and rationale.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants