Isomorphic React: the benefits, pitfalls and work-arounds
For the layman, Isomorphic React is a server-rendered client side app. Got that? Us neither. Luckily Ali Sheehan-Dare is there to talk us all through it with an expansion on his post, A Lazy Isomorphic React Experiment.
on the server initially, then continues to render on the client, using the same code. Client Server • Templates • Business logic • API Server-rendered codebase Isomorphic codebase Server Client Shared Client API Client-rendered codebase
Initial render Fetch data (AJAX) Render with data First ‘paint’ (first tweet) 557ms * ✱ Average from DO London region, without browser caching - 157Kb bundle size Isomorphic App CLIENT SERVER Request page (HTML) Fetch js Begin rendering on client First ‘paint’ (first tweet) 376ms * Fetch data from API Send HTML JavaScript behaviour initialised: - Click listeners - Client side routing Generate HTML
both client and server • Both can request data from the same API server Fetching data Separate API server Client App code (components) • Initial HTML • App code React Rendering Server API Server API data API data
Either call – API endpoints on itself – Controller functions Fetching data One server Client App code (components) • Server-side Routing • Initial HTML • App code • API data Server Internal API requests