What problem does it solve? TanStack Start developers need a structured way to run shared logic—authentication, logging, validation, context injection—across server functions and server routes without duplicating code, while avoiding subtle security and SSR pitfalls. ## Core Features & Use Cases - Two middleware types: Request middleware (.server() only, runs on all server requests) and server function middleware (.client() + .server(), runs per createServerFn call). - Context passing: Chain middleware with typed context via next({ context }), and transfer data between client and server phases using sendContext. - Global middleware: Register app-wide request and function middleware through createStart in src/start.ts. - Middleware factories: Build parameterized reusable patterns like authorizationMiddleware(permissions) for role-based access control. - Use Case: Attach an authMiddleware that loads the session from cookies to every createServerFn handling private data, then layer a permission-checking factory on top for fine-grained authorization. ## Quick Start Ask the AI to create a TanStack Start auth middleware that loads the session from request cookies and attaches it to a protected server function.