You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any context that might help us understand?
The documentation contains the following statement:
Note: While only one middleware.ts file is supported per project, you can still organize your middleware logic modularly. Break out middleware functionalities into separate .ts or .js files and import them into your main middleware.ts file. This allows for cleaner management of route-specific middleware, aggregated in the middleware.ts for centralized control. By enforcing a single middleware file, it simplifies configuration, prevents potential conflicts, and optimizes performance by avoiding multiple middleware layers.
The docs seem to imply that the mere act of importing multiple files exporting a middleware and config object is enough to use multiple middleware. But I imagine there is actually a composition step missing. Obviously middleware can be composed with function composition, but what isn't clear is how to combine multiple config objects and matchers, that is, to ensure that each middleware is associated with a given matcher.
Can we get an example of importing more than one middleware, each with its own matcher config?
Does the docs page already exist? Please link to it.
No response
The text was updated successfully, but these errors were encountered:
What is the documentation issue?
https://nextjs.org/docs/app/building-your-application/routing/middleware#convention
Is there any context that might help us understand?
The documentation contains the following statement:
The docs seem to imply that the mere act of importing multiple files exporting a
middleware
andconfig
object is enough to use multiple middleware. But I imagine there is actually a composition step missing. Obviously middleware can be composed with function composition, but what isn't clear is how to combine multipleconfig
objects and matchers, that is, to ensure that each middleware is associated with a given matcher.Can we get an example of importing more than one middleware, each with its own matcher config?
Does the docs page already exist? Please link to it.
No response
The text was updated successfully, but these errors were encountered: