agentsclimarketplace

Start execution model

Skill fusengine/agents/plugins/tanstack-start-expert/skills/start-execution-model

TanStack Start execution model — isomorphic-by-default, environment boundary functions (createServerFn, createServerOnlyFn, createClientOnlyFn, createIsomorphicFn), <ClientOnly>, useHydrated(), server-only/client-only import markers, and env-var safety (VITE_/PUBLIC_ prefix vs process.env). Use when: deciding where code runs, fixing secret leaks, DB/filesystem in a loader, hydration mismatches, "process.env is undefined on the server". Do NOT use for: initial setup (use start-core), file/directory SOLID organization (use solid-tanstack-start).From its SKILL.md

Install
npx -y skills add fusengine/agents --skill start-execution-model

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.7 KB, 974 tokens by cl100k_base, as published. Nobody here has run it

TanStack Start Execution Model

Understanding where code runs is the single most important concept in Start, and the #1 source of AI-generated bugs. Targets @tanstack/react-start v1.166.2.

CRITICAL — everything is isomorphic by default. Every module runs in BOTH the server and client bundles. Route loaders run on both — during SSR AND during client navigation. DB, filesystem, and secrets MUST live inside createServerFn (or createServerOnlyFn), never a bare loader or module scope.

CRITICAL — read process.env per request, not at module scope. Module-level reads (1) can be inlined into the client bundle (secret leak) and (2) are undefined on edge runtimes (Cloudflare Workers inject env at request time).

CRITICAL — VITE_/PUBLIC_ prefixed vars are exposed to the client. Server secrets must have NO public prefix.

Agent Workflow (MANDATORY)

Verify APIs against Context7 (/websites/tanstack_start_framework_react) + Exa before writing boundary code. After changes, run fuse-ai-pilot:sniper.


The Boundary APIs at a Glance

APIUse caseClient behaviorServer behavior
createServerFn()RPC, data, mutationsnetwork requestdirect execution
createServerOnlyFn(fn)server utilitythrowsdirect execution
createClientOnlyFn(fn)browser utilitydirect executionthrows
createIsomorphicFn()per-env implementation.client() impl.server() impl
<ClientOnly fallback>browser-only UIrenders childrenrenders fallback
useHydrated()post-hydration logictrue after hydratefalse
import '@tanstack/react-start/server-only'whole file server-onlyimport deniedallowed
import '@tanstack/react-start/client-only'whole file client-onlyallowedimport denied

All boundary creators are imported from @tanstack/react-start; <ClientOnly> and useHydrated come from @tanstack/react-router.


The One Gotcha to Remember

// ❌ WRONG — loader is isomorphic; SECRET ships to the browser
export const Route = createFileRoute('/dashboard')({
  loader: async () => {
    const secret = process.env.API_SECRET // leaked
    return fetch(url, { headers: { Authorization: secret } })
  },
})

// ✅ CORRECT — server-only work behind createServerFn
const getData = createServerFn({ method: 'GET' }).handler(async () => {
  const secret = process.env.API_SECRET // stays on the server
  return fetch(url, { headers: { Authorization: secret } })
})
export const Route = createFileRoute('/dashboard')({ loader: () => getData() })

Reference Guide

TopicReferenceLoad when
Why loaders/modules are isomorphic; the mental modelreferences/isomorphic-by-default.mddeciding server vs client vs both
Each boundary API + import markers + which to pickreferences/environment-boundaries.mdchoosing an API, marking a file
VITE_/PUBLIC_ vs process.env, per-request reads, runtime varsreferences/environment-variables.mdenv var undefined / leaked
Complete copy-paste examples of every boundaryreferences/templates/boundaries.mdwriting boundary code

Decision Framework

  • Server-only (createServerFn / createServerOnlyFn): secrets, DB, filesystem, external API keys.
  • Client-only (createClientOnlyFn / <ClientOnly>): DOM, localStorage, geolocation, analytics.
  • Isomorphic (default / createIsomorphicFn): formatting, business logic, shared utilities, loaders.

Forbidden

  • DB / secrets / filesystem in a bare loader (→ createServerFn).
  • process.env at module scope (leak + undefined on edge).
  • VITE_/PUBLIC_ prefix on a secret.
  • Non-deterministic render output (new Date() directly) → hydration mismatch.
  • Dynamic import() of a *.functions.ts server function (bundler issues).

What ships with it: 5 files

14.8 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.