tanstack-start-middleware
Installation
SKILL.md
TanStack Start middleware
Use this pattern when a shared src/start.ts must register request middleware whose implementation imports Node-only modules.
Problem
These both fail, for different reasons:
- Dynamic
import()inside.server(...)violates static-dependency and Effect lint rules. - Importing a
.server.tsmiddleware value and placing it directly increateStart({ requestMiddleware })makes TanStack Start's client import-protection plugin reject the server-only import.
Pattern
Keep the implementation in a .server.ts module and export the request handler, not the completed middleware object:
// tracing-middleware.server.ts
import type { RequestServerFn } from "@tanstack/react-start"