start-core/execution-model
Execution Model
Understanding where code runs is fundamental to TanStack Start. This skill covers the isomorphic execution model and how to control environment boundaries.
CRITICAL: ALL code in TanStack Start is isomorphic by default — it runs in BOTH server and client bundles. Route loaders run on BOTH server (during SSR) AND client (during navigation). Server-only operations MUST use
createServerFn. CRITICAL: Module-levelprocess.envaccess is wrong on two axes — security (values leak into the client bundle) AND runtime correctness (on Cloudflare Workers and other edge runtimes, env is injected per-request, so module-level reads evaluate toundefinedeven on the server). Read env inside.handler()or another per-request function, never at module scope. CRITICAL:VITE_prefixed environment variables are exposed to the client bundle. Server secrets must NOT have theVITE_prefix.