TanStack Start
TanStack Start is a full-stack React framework built on Vite, so there’s no dedicated TanStack Start package — which integration you use depends on where you deploy.
- Node / Vercel / Netlify / self-hosted — use the Vite integration. See setup below.
- Cloudflare Workers — use the Cloudflare integration. See Cloudflare setup below.
Check out the TanStack Start example project for a working reference.
Setup (vite integration)
Section titled “Setup (vite integration)”For any deployment target other than Cloudflare Workers, use varlockVitePlugin from the Vite integration.
-
Install packages
Terminal window npm install @varlock/vite-integration varlockTerminal window pnpm add @varlock/vite-integration varlockTerminal window bun add @varlock/vite-integration varlockTerminal window yarn add @varlock/vite-integration varlockTerminal window vlt install @varlock/vite-integration varlock -
Run
varlock initto set up your.env.schemaThis will guide you through setting up your
.env.schemafile, based on your existing.envfile(s). Make sure to review it carefully.Terminal window npm exec -- varlock initTerminal window pnpm exec -- varlock initTerminal window bun exec varlock initTerminal window vlx -- varlock initTerminal window yarn exec -- varlock init -
Add the plugin to your Vite config
app.config.ts import { defineConfig } from '@tanstack/react-start/config';import { tanstackStart } from '@tanstack/react-start/plugin/vite'import { varlockVitePlugin } from '@varlock/vite-integration';export default defineConfig({vite: {plugins: [varlockVitePlugin(),tanstackStart(),],},});
Setup for Cloudflare Workers
Section titled “Setup for Cloudflare Workers”If you’re deploying your TanStack Start app to Cloudflare Workers, use varlockCloudflareVitePlugin from the Cloudflare integration instead.
-
Install packages
You must also install
@cloudflare/vite-pluginas a peer dependency.Terminal window npm install @varlock/cloudflare-integration @cloudflare/vite-plugin varlockTerminal window pnpm add @varlock/cloudflare-integration @cloudflare/vite-plugin varlockTerminal window bun add @varlock/cloudflare-integration @cloudflare/vite-plugin varlockTerminal window yarn add @varlock/cloudflare-integration @cloudflare/vite-plugin varlockTerminal window vlt install @varlock/cloudflare-integration @cloudflare/vite-plugin varlock -
Run
varlock initto set up your.env.schemaTerminal window npm exec -- varlock initTerminal window pnpm exec -- varlock initTerminal window bun exec varlock initTerminal window vlx -- varlock initTerminal window yarn exec -- varlock init -
Add the Cloudflare Vite plugin
app.config.ts import { defineConfig } from '@tanstack/react-start/config';import { tanstackStart } from '@tanstack/react-start/plugin/vite'import { varlockCloudflareVitePlugin } from '@varlock/cloudflare-integration';export default defineConfig({vite: {plugins: [varlockCloudflareVitePlugin(),tanstackStart(),// ...],},}); -
Deploy with
varlock-wranglerUse
varlock-wrangler deployinstead ofwrangler deployin your deploy script:package.json {"scripts": {"deploy": "varlock-wrangler deploy"}}If you deploy via Cloudflare Workers Builds instead of a local/CI script, override the deploy command in your Cloudflare dashboard under Settings → Build → Deploy command — see Workers Builds below.
Deploying via Cloudflare Workers Builds
Section titled “Deploying via Cloudflare Workers Builds”If you deploy through Cloudflare Workers Builds, two pieces of configuration must be set in the dashboard — neither can be committed to the repo:
- Override the Deploy command — Under Settings → Build → Deploy command, replace the default
npx wrangler deploywithnpx varlock-wrangler deploy. Without this, Cloudflare runs stockwrangler deploy, which skips varlock resolution and leaves your worker without its resolved vars/secrets. - Set any secret-zero vars under Build variables — Any env vars varlock itself needs during load (e.g. a 1Password service account token, a GCP key) must be set under Settings → Build → Variables and Secrets so they’re available at build time.
varlock-wrangler deploythen resolves your full env graph and uploads the result to the worker runtime as regular vars/secrets.
See the Cloudflare integration page for more detail on varlock-wrangler and Workers Builds configuration.
Compared to TanStack Start’s built-in env var handling
Section titled “Compared to TanStack Start’s built-in env var handling”TanStack Start inherits Vite’s env var approach: process.env on the server and import.meta.env on the client, with only VITE_-prefixed vars exposed client-side. Their docs recommend maintaining a manual src/env.d.ts for TypeScript support and separate Zod schemas for runtime validation.
With varlock, your .env.schema is the single source of truth — it handles validation, type coercion, TypeScript generation, sensitivity controls, and more, replacing the need for separate type declarations, Zod schemas, and the VITE_ prefix convention. You also get leak detection (sensitive values are automatically scrubbed from outgoing HTTP responses) and clear error messages when env vars are missing or invalid — no more silent undefined values at runtime. See the Vite integration page for the full details.