execution-model
БесплатноБез исполняемых скриптовНе проверенIsomorphic-by-default principle, environment boundary functions (createServerFn, createServerOnlyFn, createClientOnlyFn, createIsomorphicFn), ClientOnly…
от TanStack★ 15 408 звёзд на GitHubОб этом скилле
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. CRITICAL: Relative URLs belong to browser-only code. An isomorphic loader also runs during SSR, wherefetch('/api/...')may have no base URL. Call a server function from the loader, or keep the fetch inside an explicit environment boundary.
Execution Control APIs
| API | Use Case | Client Behavior | Server Behavior |
|---|---|---|---|
createServerFn() |
RPC calls, data mutations | Network request to server | Direct execution |
createServerOnlyFn(fn) |
Utility functions | Throws error | Direct execution |
createClientOnlyFn(fn) |
Browser utilities | Direct execution | Throws error |
createIsomorphicFn() |
Different impl per env | Uses .client() impl |
Uses .server() impl |
<ClientOnly> |
Browser-only components | Renders children | Renders fallback |
useHydrated() |
Hydration-dependent logic | true after hydration |
false |
import '@tanstack/<fw>-start/server-only' |
Mark whole file server-only | Import denied | Allowed |
import '@tanstack/<fw>-start/client-only' |
Mark whole file client-only | Allowed | Import denied |
Server-Only Execution
createServerFn (RPC pattern)
The primary way to run server-only code. On the client, calls become fetch requests:
// Use @tanstack/<framework>-start for your framework (react, solid, vue)
import { createServerFn } from '@tanstack/react-start'
const fetchUser = createServerFn().handler(async () => {
const secret = process.env.API_SECRET // safe — server only
return await db.users.find()
})
// Client calls this via network request
const user = await fetchUser()
createServerOnlyFn (throws on client)
For utility functions that must never run on client:
// Use @tanstack/<framework>-start for your framework (react, solid, vue)
import { createServerOnlyFn } from '@tanstack/react-start'
const getSecret = createServerOnlyFn(() => process.env.DATABASE_URL)
// Server: returns the value
// Client: THROWS an error
Client-Only Execution
createClientOnlyFn
// Use @tanstack/<framework>-start for your framework (react, solid, vue)
import { createClientOnlyFn } from '@tanstack/react-start'
const saveToStorage = createClientOnlyFn((key: string, value: string) => {
localStorage.setItem(key, value)
})
ClientOnly Component
// Use @tanstack/<framework>-router for your framework (react, solid, vue)
import { ClientOnly } from '@tanstack/react-router'
function Analytics() {
return (
<ClientOnly fallback={null}>
<GoogleAnalyticsScript />
</ClientOnly>
)
}
useHydrated Hook
// Use @tanstack/<framework>-router for your framework (react, solid, vue)
import { useHydrated } from '@tanstack/react-router'
function TimeZoneDisplay() {
const hydrated = useHydrated()
const timeZone = hydrated
? Intl.DateTimeFormat().resolvedOptions().timeZone
: 'UTC'
return <div>Your timezone: {timeZone}</div>
}
Behavior: SSR → false, first client render → false, after hydration → true (stays true).
Environment-Specific Implementations
// Use @tanstack/<framework>-start for your framework (react, solid, vue)
import { createIsomorphicFn } from '@tanstack/react-start'
const getDeviceInfo = createIsomorphicFn()
.server(() => ({ type: 'server', platform: process.platform }))
.client(() => ({ type: 'client', userAgent: navigator.userAgent }))
Import Protection: File Markers
Experimental.
The .server.* and .client.* filename suffixes (e.g. db.server.ts) opt a file into Start's import protection — it can't
Установить execution-model в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл execution-model?
Isomorphic-by-default principle, environment boundary functions (createServerFn, createServerOnlyFn, createClientOnlyFn, createIsomorphicFn), ClientOnly component, useHydrated hook, import protection, dead code elimination, environment variable safety (VITE_ prefix, process.env).
Как установить скилл execution-model?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл execution-model запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic