Native esm React example.
- An example React application rendering two svg logos.
- An http server that:
- serves the above application, providing both the SSR (
http://localhost:3000/
) and client-only (http://localhost:3000/index.html
) approaches. - uses a worker thread to separate app evaluation/rendering from http server.
- supports live reloading of the SSR renderer and connected clients.
- is not production-ready, as there's no caching, compression, etc.
- serves the above application, providing both the SSR (
- Both application and server are compiled into a single ESM output that works natively in Node.js AND browsers that support import maps.
- Source maps work in Node and browsers. Nicer debugging experience compared to CommonJS, as imported symbol names are kept the same.
- Asset references using
new URL('./asset.svg, import.meta.url)
are shown and work for SSR as well. Assets must live outside thesrc
tree so relative references fromdist
work. - A really cool
"start"
script that triggers server reloading while giving atsc -w
like experience. - Tiny amount of dev/runtime dependencies.
npm i
and look atnode_modules
. - React itself is not published as native ESM, so the files in the
static/esm-bridge
folder allow browser ESM imports to use the UMD versions ofreact
/react-dom
, which are loaded byindex.html
. - Written using strict TypeScript.
- Clone repository.
npm i
npm start
- Open
http://localhost:3000/
in a browser compatible with import maps.
MIT