T
TanStack3mo ago
other-emerald

process.env works in local development but is missing after deploying to cloudflare workers

client-side secrets through import.meta.env work both locally and on deployed worker. Server-side secrets using process.env doesn't exist when deployed. I'm using workers not pages using these as reference: https://developers.cloudflare.com/workers/framework-guides/web-apps/tanstack/ https://charleswilliamson.com/how-to-deploy-tanstack-start-to-cloudflare-workers/
{
"name": "web",
"$schema": "node_modules/wrangler/config-schema.json",
"compatibility_flags": ["nodejs_compat", "nodejs_compat_populate_process_env"],
"compatibility_date": "2025-04-01",
"main": ".output/server/index.mjs",
"observability": {
"enabled": true,
},
"assets": {
"directory": "./.output/public/",
}
}
{
"name": "web",
"$schema": "node_modules/wrangler/config-schema.json",
"compatibility_flags": ["nodejs_compat", "nodejs_compat_populate_process_env"],
"compatibility_date": "2025-04-01",
"main": ".output/server/index.mjs",
"observability": {
"enabled": true,
},
"assets": {
"directory": "./.output/public/",
}
}
Cloudflare Docs
TanStack
Create a TanStack Router application and deploy it to Cloudflare Workers with Workers Assets.
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
2 Replies
other-emerald
other-emeraldOP3mo ago
Just had to upload the secrets to the worker using wrangler.
conscious-sapphire
conscious-sapphire3mo ago
GitHub
GitHub - bonadio/tanstack-start-cloudflare-workers
Contribute to bonadio/tanstack-start-cloudflare-workers development by creating an account on GitHub.

Did you find this page helpful?