Supabase Middleware: composable, reusable middleware for Web Fetch handlers

Impact 7 Supabase Blog

Summary

  • Supabase has released @supabase/middleware, composable, type-safe middleware for Web Fetch handlers that can run on any fetch-compatible runtime.
  • The middleware works across various runtimes including Edge Functions, Vercel Functions, Cloudflare Workers, Deno, Bun, and Node 22+.
  • Bridges are provided to allow the same middleware to run inside web frameworks like Hono, H3, Elysia, NestJS, and TanStack Start.
  • Built-in middleware entries handle standard tasks such as CORS, feature flags, JWT claims verification, database clients, and OAuth protected-resource flows for MCP clients.
  • Developers can use defineMiddleware to create custom typed middleware entries that add specific keys to a shared request context.

Why it matters

This release allows developers to write per-request logic, authentication, and routing rules once and execute them seamlessly across multiple serverless runtimes and web frameworks without rewriting.

Who should care