Cloudflare workers vs pages
I'm building a full stack sveltekit app (svelte code on both frontend and backend).
I'm confused whether I should deploy it to cloudflare workers or cloudflare pages?
On one hand, it seems like pages is intended for static sites and workers is intended for dynamic backends. On the other hand, I see conflicting information where it seems sites deployed to pages can have dynamic backend content.
What things should I consider when picking workers vs pages?
4 Replies
Pages can have Workers (called Functions) as well so full stack sites can be hosted
Recommendation for sites is always Pages these days
If I have a full stack sveltekit site and host it on pages, do the backend things automatically get run in workers/functions?
Briefly looking through the pages functions docs and it mentions a
/functions
folder.
I'm guessing sveltekit's build output creates this? Otherwise it would break the framework's model (file-based routing where each page has its own load function for db/api calls/etc)Yeah Svelte will handle generating the Function/Worker
https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/
https://kit.svelte.dev/docs/adapter-cloudflare
"Recommendation for sites is always Pages these days" Can you elaborate on this? I can't really get difference between Pages and Workers. For me it seems like Pages is a level of abstraction / an additional layer on top of workers to make it easier to use for sites. Is this the case?