fetch-router@0.20.0
Breaking Changes📦 remixView on GitHub →
⚠ 2 breaking✨ 5 features🐛 1 fixes🔧 12 symbols
Summary
This release introduces router mounting for reusable route groups and significantly updates middleware behavior to require explicit continuation or response return, improving error detection. It also enhances context inference for actions and controllers based on inline middleware.
⚠️ Breaking Changes
- Middleware must now explicitly continue the request chain by calling `next()` or return a `Response`. The router no longer calls `next()` automatically when middleware returns `undefined`; it throws an error instead.
- The `MapTarget` and `MapHandler` types are no longer exported. Use the public `Router`, `RouteBuilder`, `RouteInstaller`, `Action`, and `Controller` types instead.
Migration Steps
- Ensure all middleware functions explicitly call `next()` and return its result, or return a `Response` object.
- If middleware only mutates context, it should return the result of `next()` (e.g., `return next()`).
- If middleware needs to inspect or modify the downstream response, it must `await next()` and return the resulting response (e.g., `let response = await next(); return response`).
✨ New Features
- Added `router.mount()` and the `RouteBuilder`/`RouteInstaller` types to allow route groups to be written as local, reusable pieces of an app.
- Mount prefixes used in `router.mount()` are now route patterns, making params from the prefix available in mounted handlers.
- Added `RouterContext<typeof router>` for extracting the request context provided by a router or route builder.
- Middleware context inference for `createAction()`, direct action objects, single-route `map()`, method helpers, and `createController()` now correctly infers values from plain inline middleware arrays.
- Added `createMiddleware()` for cases where a reusable middleware chain must preserve its exact tuple type without `as const`.
🐛 Bug Fixes
- Middleware that returned `undefined` instead of continuing the chain now correctly throws an error instead of implicitly continuing.