r/reactjs • u/Tasty_Management_857 • 2d ago
Discussion What does React handle when a page hydrates? I built a renderer to find out
I maintain Farm.js. React is our default renderer, but apps can bring their own. I built a small UI library called Leaf to try that with an app that had no React dependency.
The surprise was where React showed up. Leaf could render a button as HTML on the server, but the development client loaded React through a router import. The page could render, then fail to hydrate. Testing with React already installed had hidden that dependency.
We gave the router its own entry point. The test I care about now is small: in an app without React, can I click the server-rendered button and navigate to another page without a reload?
If you maintain a library with an optional React adapter, how do you test that React stays optional?
Walkthrough: https://farmjs.dev/blog/bring-your-own-renderer Source: https://github.com/farming-labs/leaf
9
u/Honey-Entire 2d ago edited 1d ago
Have you avoided reading any of the hydration blogs and articles posted on here the past 3-5 years? Instead you prompted Claude to rewrite an existing breakdown of known tech? Cool cool cool, gg OP
1
u/Keyaman 2d ago
The bit about the router import quietly pulling React in is the real trap, since your tests with React already installed would never catch it. For the optional adapter question, I'd add a CI job that installs the package with peer deps omitted and asserts a click plus navigation still works without a reload.