What problem does it solve? It provides a structured way to run shared logic before and after route handlers in a Rango router, so authentication, logging, rate limiting, and request context setup do not have to be duplicated inside every route handler. ## Core Features & Use Cases - Two execution scopes: Register global middleware with router.use() to wrap entire requests including server actions, or route middleware with middleware() inside urls() to wrap rendering only. - Typed context sharing: Pass data from middleware to handlers using ctx.set/ctx.get with createVar<T>() or Rango.Vars augmentation for type-safe request state. - Common patterns included: Ready-made examples for auth guards, permission checks, request logging, KV-backed rate limiting, redirects with flash state, and build-time PPR shell middleware. - Use Case: Protect an /admin section by registering router.use("/admin/*", requireAuth) so both page renders and server actions are gated, while a route-level middleware sets per-render context variables. ## Quick Start Add an authentication middleware to my Rango router that protects all routes under /admin and redirects unauthenticated users to /login.