tanstack-start-best-practices
1.3K
总安装量
1.3K
周安装量
#313
全站排名
安装命令
npx skills add https://github.com/deckardger/tanstack-agent-skills --skill tanstack-start-best-practices
Agent 安装分布
opencode
1.2K
codex
1.2K
gemini-cli
1.2K
amp
1.1K
kimi-cli
1.0K
Skill 文档
TanStack Start Best Practices
Comprehensive guidelines for implementing TanStack Start patterns in full-stack React applications. These rules cover server functions, middleware, SSR, authentication, and deployment.
When to Apply
- Creating server functions for data mutations
- Setting up middleware for auth/logging
- Configuring SSR and hydration
- Implementing authentication flows
- Handling errors across client/server boundary
- Organizing full-stack code
- Deploying to various platforms
Rule Categories by Priority
| 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 |
Quick Reference
Server Functions (Prefix: 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 needed
Security (Prefix: sec-)
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 mutations
Middleware (Prefix: mw-)
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 effectively
Authentication (Prefix: auth-)
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 settings
API Routes (Prefix: api-)
api-routesâ Create API routes for external consumers
SSR (Prefix: ssr-)
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 ISR
Environment (Prefix: env-)
env-functionsâ Use environment functions for configuration
Error Handling (Prefix: err-)
err-server-errorsâ Handle server function errorserr-redirectsâ Use redirects appropriatelyerr-not-foundâ Handle not-found scenarios
File Organization (Prefix: file-)
file-separationâ Separate server and client codefile-functions-fileâ Use .functions.ts patternfile-shared-validationâ Share validation schemas
Deployment (Prefix: deploy-)
deploy-env-configâ Configure environment variablesdeploy-adaptersâ Choose appropriate deployment adapter
How to Use
Each rule file in the rules/ directory contains:
- Explanation â Why this pattern matters
- Bad Example â Anti-pattern to avoid
- Good Example â Recommended implementation
- Context â When to apply or skip this rule
Full Reference
See individual rule files in rules/ directory for detailed guidance and code examples.