Hosting SvelteKit as SSR on mittwald SpaceServer
Tags: sveltekit, node, devops, webdev
Published: 2023-05-12 21:31:58

The green webhosting company [mittwald](https://www.mittwald.de/) (Germany) launched two new products with support for [NodeJS Server Side Rendering (SSR)](https://dev.to/mandrasch/nodejs-server-side-rendering-ssr-do-we-really-need-it-1cp2): 

The [mittwald SpaceServer](https://www.mittwald.de/space-server) and the [mittwald proSpace](https://www.mittwald.de/prospace).

![Screenshot mittwald product configurator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lh2da46dd97hs8nhhlsu.png)

The SpaceServer can be tested freely for 10 days. 

For testing I used the official SvelteKit demo application `npm create svelte@latest my-app` and switched to SvelteKits [adapter-node](https://kit.svelte.dev/docs/adapter-node). 

The sverdle subpage demonstrates the benefits of SSR - the solution of the quiz is handled securely on  server side (`+page.server.js`).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0occwkc551f6rotr2uon.png)

Here are some impressions:

**Create a new project**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5nt3a7dri8sdewg07lay.png)

**Create an app within this project**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2xvfvu9k0k6hepxskwd.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rjr8jjsak8abmunwpxxy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ix554fimb52nz748f97e.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6qbzao7zvh18jf3g8wb.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s1iaj1yb369w38yha7i.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exyfm72wealyv0pica0c.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nhgddfjclxdoc2sbkvw0.png)

**Test domains**

All projects have automatically a subdomain assigned:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87capodtxjhvjh0bkhj4.png)

**Monitoring the server load**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/piqtdzzg2kujx79qdh60.png)

**Start and stop via SSH**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6hg0q2ict1es1e7olea.png)

Important information: I ran into some minor issues because I had my SSH session open and edited the app configuration in the web dashboard at the same time. Currently you need to exit the SSH session after changes so that the currently running app instance can be shutdown. I ended up having multiple SvelteKit apps online on the same port competing for serving the first request (and generating random 404 / 502 errors). ;-) But this will be improved in future according to mittwalds very helpful support team.

## Conclusion

I really enjoyed working with the mStudio dashboard and the SpaceServer! 

SSH keys can be assigned per project (or globally per member of the space server) and external domains can be connected for free (including free SSL certificates). There is also a support chat where you can directly get in touch with the Mittwald support team.

For personal hobby projects, the starting price of 35€/month for the [SpaceServer](https://www.mittwald.de/space-server) is of course a bit much. But for freelancers or agencies a fixed price managed server which also can be scaled up or down is a great deal in my opinion. The [proSpace](https://www.mittwald.de/prospace) is also an interesting deal for bigger sized projects and requirements.

_There is also the [AgenturServer](https://www.mittwald.de/agentur-server) product where NodeJS can be added for 9€/month to individually scalable projects._

Congrats to mittwald for introducing this awesome product! 👏👏👏 It is so amazing to finally see a comfortable and easy NodeJS SSR hosting offer in the EU with full GDPR-compliance. 🇪🇺 mittwald is also verified by the [Green Web Directory](https://www.thegreenwebfoundation.org/directory/). 🌱

I really hope that other webhosting companies will follow and that NodeJS SSR will be easily available for more developers in future!

### Technical notes regarding SvelteKits adapter-node

The default start command for adapter-node is `node build`. Beware: For adapter-node usage you will need to transfer some more project files, not only the `build/`-folder. See [adapter-node docs](https://kit.svelte.dev/docs/adapter-node) for more information. Some files in `node_modules/` are needed as well. 

I originally tried using rsync via GitHub action, but couldn't figure out how to optimize the node_module dependencies. See my demo repo https://github.com/mandrasch/sveltekit-mittwald-spaceserver-demo. This is entirely a GitHub Action problem / challenge, not a problem of the SpaceServer. For now I would rather suggest starting with `git clone ...` and `npm install && npm run build` on the server (and trigger these commands via GitHub Action and SSH). To be continued ... 🤔