Overview
The svelte-ssr-worker is a demo project that demonstrates how to render a Svelte server-side (SSR) application within a Cloudflare Worker. It is a minimal extension of the official svelte-template.
Features
- Svelte server-side rendering within a Cloudflare Worker
- Builds the client for production using the src/index.dom.js entry point
- Builds the Cloudflare Worker code using the src/index.ssr.js entry point
- Includes scripts for local development server and watching for changes
- Easy deployment using Cloudflare’s wrangler tool
Installation
To install the svelte-ssr-worker, follow these steps:
- Set up a storage bucket and attach it to a CDN.
- Update the {{/CDN/}} value within the config/shared.js file with the CDN address.
- Upload the contents of the
/publicdirectory to your storage bucket. - Upload the
build/index.jsfile to Cloudflare Workers.- Note: Cloudflare’s wrangler tool can handle both of these steps efficiently.
That’s it! You have successfully installed the svelte-ssr-worker.
Summary
The svelte-ssr-worker is a demo project that showcases how to implement Svelte server-side rendering within a Cloudflare Worker. It provides an easy-to-follow installation guide and includes several useful features for development and deployment. This project can serve as a starting point for building SSR applications with Svelte in a Cloudflare environment.