npm install
npm run start
The major problem when doing SSR is that you will need to ship the DB data two times to the client:
For certain use cases this can be very wasteful.
As an example see Sapper HN. Right-click, open the source, and scroll to the bottom. There is a huge chunk of JSON. This is only an illustrative example though because Sapper only uses SSR in the first request.
If you run this proof of concept and look at the generated source you'll see only the data for the hydrated components is included in the JSON object:
const HYDRATION_DATA = {"Colors_1":{"colors":["Red","Blue","Yellow"]},"Colors_2":{"colors":["Purple","Magenta","Orange"]}};
Also, only the JavaScript for the hydrated components is loaded:
This is a very basic proof of concept and doesn't solve a number of things:
.js
files like I did on my Svelte SSR example if your SSR server is running on Node (eg: Heroku). If you are doing SSR serverless you can create a list of the files after Rollup ends up bundling and import/require that in your cloud function.