brophdawg11 / raw-react-ssr

Simple React SSR + Hydration examples without a framework or bundler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raw React SSR

This repo contains 2 node HTTP server files that show how React SSR + hydration works without any framework or bundler. Therefore no JSX is used and React scripts are loaded from unpkg.

Hydrating a div

server-hydrate-div.mjs shows an example where only a <div id="app"> is hydrated and the node server manages the rendering of <html>/<head>/<body>/<script>/etc tags.

npm ci
node server-hydrate-div.mjs

Hydrating the full document

server-hydrate-doc.mjs shows an example where the entire <html> document is hydrated (this is a common approach for Meta Frameworks such as Remix or Next.js).

npm ci
node server-hydrate-doc.mjs

About

Simple React SSR + Hydration examples without a framework or bundler


Languages

Language:JavaScript 100.0%