Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR support #1

Open
JakubKoralewski opened this issue Jan 28, 2021 · 2 comments
Open

SSR support #1

JakubKoralewski opened this issue Jan 28, 2021 · 2 comments

Comments

@JakubKoralewski
Copy link

I see your template does not currently support SSR on the edge. Is this something you have considered?

@jpwilliams
Copy link
Owner

I haven't looked in to that before on Cloudflare workers.

What would it look like? :)

@JakubKoralewski
Copy link
Author

Originally done by lukeed, this can give you an idea: https://github.com/lukeed/svelte-ssr-worker/blob/master/src/index.ssr.js

I'd personally consider using Cloudflare Workers' built in HTMLRewriter API instead of the string .replace() calls.

wtcross built on it further to integrate with Worker Sites:

https://github.com/wtcross/svelte-ssr-cloudflare-worker-site

But I think he only set up SSR for the index page, and rest is usual html files with Worker Sites?

Please don't assume I know what I'm talking about, just asking and suggesting so I may be saying stupid things below

I think it could be improved by both integrating TypeScript, using the HTMLRewriter api, adding SSR routing to all pages (not a SPA at this point) and maybe somehow detecting that a page is static and caching it in Workers?

I'm very curious about the possibilities of merging Svelte and Cloudflare Workers, I'm sure more optimizations could be done by hooking into the Svelte compiler during SSR and cache some intermediate outputs in Cloudflare's KV and other caches, but I'm not familiar enough with Svelte intrinscs for that. Just dreaming big :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants