---
title: Middleware
source: https://github.com/remix-run/remix/blob/remix@3.0.0-beta.2/packages/fetch-router/src/lib/middleware.ts#L74
---

# Middleware

## Summary

Handles a request and optionally delegates to the next middleware or handler.

## Signature

```ts
interface Middleware {
  (
    context: RequestContext<any>,
    next: NextFunction,
  ): void | Response | Promise<void | Response | undefined> | undefined;
}

```