#Deploying on cloudflare? what are the best practise to deal with env variables?

4 messages · Page 1 of 1 (latest)

lone pecan
#

when to retrieve env secret for examples for the database connection, or event better-auth settings?
on global context?
using a global middleware?

neat knoll
#

This might be helpful to you: https://developers.cloudflare.com/workers/framework-guides/web-apps/tanstack/

It's good to know that env vars and secrets are exposed on process.env for newer cloudflare workers (along with other bindings).

You can also import the env bindings from the workers:cloudflare package, which for now only works in production afaik. This might change when Tanstack Start decouples from Nitro and we can use the official Cloudflare Vite plugin instead:

import { env } from "cloudlfare:workers"
Cloudflare Docs

Create a TanStack Start application and deploy it to Cloudflare Workers with Workers Assets.

lone pecan
#

oh nice, missed the bindings.ts

#

didnt know they were a de-nitro going on