Skip to content

Uvacoder/snowpack-react-ssr

Repository files navigation

snowpack-react-ssr

Minimal example using React server side rendering with snowpack.

Features

  • Babel node for server side jsx support
  • renderToNodeStream for improved server rendering performance
  • React Refresh works via Snowpack
  • Inlines CSS server side for optimal first contentful paint

Usage

npm install
npm run start

This will launch a server and client dev server, they can be invoked separately:

npm run server

Will run on port 3000 by default.

npm run client

Will run on port 8080 by default.

Server reloading conflicts with hot reloading since a full refresh is needed for server rendered html updates to show. Included is a separate npm script that will restart the server when changes are made to the src directory.

npm run serve

Production build

npm run build

Included is the webpack plugin to optimize the client build. Also included is modulepreload script tags. To run the server in production mode:

npm run production