tanstack-start-best-practices by deckardger/tanstack-agent-skills
npx skills add https://github.com/deckardger/tanstack-agent-skills --skill tanstack-start-best-practices在完整堆栈 React 应用程序中实施 TanStack Start 模式的全面指南。这些规则涵盖了服务器函数、中间件、SSR、身份验证和部署。
| 优先级 | 类别 | 规则数量 | 影响 |
|---|---|---|---|
| 关键 | 服务器函数 | 5 条规则 | 核心数据变更模式 |
| 关键 | 安全性 | 4 条规则 | 防止漏洞 |
| 高 | 中间件 | 4 条规则 | 请求/响应处理 |
| 高 | 身份验证 | 4 条规则 | 安全的用户会话 |
| 中 | API 路由 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 1 条规则 |
| 外部端点模式 |
| 中 | SSR | 6 条规则 | 服务器渲染模式 |
| 中 | 错误处理 | 3 条规则 | 优雅的故障处理 |
| 中 | 环境 | 1 条规则 | 配置管理 |
| 低 | 文件组织 | 3 条规则 | 可维护的代码结构 |
| 低 | 部署 | 2 条规则 | 生产就绪性 |
sf-)sf-create-server-fn — 使用 createServerFn 处理服务器端逻辑sf-input-validation — 始终验证服务器函数输入sf-method-selection — 选择合适的 HTTP 方法sf-error-handling — 在服务器函数中处理错误sf-response-headers — 需要时自定义响应头sec-)sec-validate-inputs — 使用模式验证所有用户输入sec-auth-middleware — 使用身份验证中间件保护路由sec-sensitive-data — 仅将敏感数据保留在服务器端sec-csrf-protection — 为变更操作实施 CSRF 保护mw-)mw-request-middleware — 使用请求中间件处理横切关注点mw-function-middleware — 为服务器函数使用函数中间件mw-context-flow — 通过中间件正确传递上下文mw-composability — 有效组合中间件auth-)auth-session-management — 实施安全的会话处理auth-route-protection — 使用 beforeLoad 保护路由auth-server-functions — 在服务器函数中验证身份验证auth-cookie-security — 配置安全的 Cookie 设置api-)api-routes — 为外部使用者创建 API 路由ssr-)ssr-data-loading — 为 SSR 适当地加载数据ssr-hydration-safety — 防止注水不匹配ssr-streaming — 实施流式 SSR 以实现更快的 TTFBssr-selective — 在有益时应用选择性 SSRssr-prerender — 配置静态预渲染和 ISRenv-)env-functions — 使用环境函数进行配置err-)err-server-errors — 处理服务器函数错误err-redirects — 适当地使用重定向err-not-found — 处理未找到场景file-)file-separation — 分离服务器和客户端代码file-functions-file — 使用 .functions.ts 模式file-shared-validation — 共享验证模式deploy-)deploy-env-config — 配置环境变量deploy-adapters — 选择合适的部署适配器rules/ 目录中的每个规则文件包含:
有关详细指导和代码示例,请参阅 rules/ 目录中的各个规则文件。
每周安装量
2.5K
仓库
GitHub 星标数
82
首次出现
2026年1月20日
安全审计
安装于
opencode2.3K
codex2.2K
gemini-cli2.2K
github-copilot2.2K
amp2.1K
kimi-cli2.1K
Comprehensive guidelines for implementing TanStack Start patterns in full-stack React applications. These rules cover server functions, middleware, SSR, authentication, and deployment.
| Priority | Category | Rules | Impact |
|---|---|---|---|
| CRITICAL | Server Functions | 5 rules | Core data mutation patterns |
| CRITICAL | Security | 4 rules | Prevents vulnerabilities |
| HIGH | Middleware | 4 rules | Request/response handling |
| HIGH | Authentication | 4 rules | Secure user sessions |
| MEDIUM | API Routes | 1 rule | External endpoint patterns |
| MEDIUM | SSR | 6 rules | Server rendering patterns |
| MEDIUM | Error Handling | 3 rules | Graceful failure handling |
| MEDIUM | Environment | 1 rule | Configuration management |
| LOW | File Organization | 3 rules | Maintainable code structure |
| LOW | Deployment | 2 rules | Production readiness |
sf-)sf-create-server-fn — Use createServerFn for server-side logicsf-input-validation — Always validate server function inputssf-method-selection — Choose appropriate HTTP methodsf-error-handling — Handle errors in server functionssf-response-headers — Customize response headers when neededsec-)sec-validate-inputs — Validate all user inputs with schemassec-auth-middleware — Protect routes with auth middlewaresec-sensitive-data — Keep secrets server-side onlysec-csrf-protection — Implement CSRF protection for mutationsmw-)mw-request-middleware — Use request middleware for cross-cutting concernsmw-function-middleware — Use function middleware for server functionsmw-context-flow — Properly pass context through middlewaremw-composability — Compose middleware effectivelyauth-)auth-session-management — Implement secure session handlingauth-route-protection — Protect routes with beforeLoadauth-server-functions — Verify auth in server functionsauth-cookie-security — Configure secure cookie settingsapi-)api-routes — Create API routes for external consumersssr-)ssr-data-loading — Load data appropriately for SSRssr-hydration-safety — Prevent hydration mismatchesssr-streaming — Implement streaming SSR for faster TTFBssr-selective — Apply selective SSR when beneficialssr-prerender — Configure static prerendering and ISRenv-)env-functions — Use environment functions for configurationerr-)err-server-errors — Handle server function errorserr-redirects — Use redirects appropriatelyerr-not-found — Handle not-found scenariosfile-)file-separation — Separate server and client codefile-functions-file — Use .functions.ts patternfile-shared-validation — Share validation schemasdeploy-)deploy-env-config — Configure environment variablesdeploy-adapters — Choose appropriate deployment adapterEach rule file in the rules/ directory contains:
See individual rule files in rules/ directory for detailed guidance and code examples.
Weekly Installs
2.5K
Repository
GitHub Stars
82
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode2.3K
codex2.2K
gemini-cli2.2K
github-copilot2.2K
amp2.1K
kimi-cli2.1K
99,500 周安装