T
TanStack4mo ago
extended-yellow

Cloudflare Workers Hosting - Docs

Hello, I noticed the docs today only mention hosting via Cloudflare Pages. It would be great to have 1-st class docs for Cloudflare Worker deployments too --- i managed to do this manually via https://charleswilliamson.com/how-to-deploy-tanstack-start-to-cloudflare-workers/ using:
server: {
preset: 'cloudflare-module',
unenv: cloudflare,
},
server: {
preset: 'cloudflare-module',
unenv: cloudflare,
},
Charles Williamson
How to deploy Tanstack Start to Cloudflare Workers
TanStack Start is currently in beta - this blog post works, as of 20/4/2025. I will aim to periodically return to this blog post and update it, if any braking changes have been released Why Workers instead of Pages? The Tanstack Start hosting page currently has a section
8 Replies
plain-purple
plain-purple3mo ago
Thanks for the guide! How do you deal with .env variables?
correct-apricot
correct-apricot3mo ago
This used to work for me before devinxi. The preset value moved to the target inside the new Vite plugin, but I'm not sure where/how to configure the unenv value.
tanstackStart({
target: "cloudflare_module",
})
tanstackStart({
target: "cloudflare_module",
})
Any idea how to pass unenv?
plain-purple
plain-purple3mo ago
Having the same issue
optimistic-gold
optimistic-gold3mo ago
Hi, I create this tamplate to host on Cloudflare using workers. https://github.com/bonadio/tanstack-start-cloudflare-workers
GitHub
GitHub - bonadio/tanstack-start-cloudflare-workers
Contribute to bonadio/tanstack-start-cloudflare-workers development by creating an account on GitHub.
correct-apricot
correct-apricot3mo ago
This worked before devinxi ☝️ Your example is still for vinxi unfortunately.
inland-turquoise
inland-turquoise3mo ago
you don't need to pass unenv in my experience
optimistic-gold
optimistic-gold3mo ago
Hi @telliks now https://github.com/bonadio/tanstack-start-cloudflare-workers works wit version 1.121
GitHub
GitHub - bonadio/tanstack-start-cloudflare-workers
Contribute to bonadio/tanstack-start-cloudflare-workers development by creating an account on GitHub.
correct-apricot
correct-apricot3mo ago
It probably depends on what other dependencies you are using. In my case, I am using Supabase which I suspect is the one using the ws package. Just for reference for anyone else that run into similar issues. I had to ultimately use Cloudflare Workers module aliases to alias the ws package used by Supabase and I had to force set the DEBUG env var to the "false" string. Kept running into an error that said ".split is not a function", which was caused by split being called on the false boolean. I didn't dig enough to know exactly which tool set process.env.DEBUG to false. I did not explicitly set it.

Did you find this page helpful?