Skip to content

Commit 3db1fab

Browse files
committed
docs: clarify middleware location (root or /src; /app not supported)
1 parent 6316c4b commit 3db1fab

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/01-app/03-api-reference/03-file-conventions/middleware.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ export const config = {
4848

4949
## Exports
5050

51+
> **Note**
52+
> Place `middleware.{js,ts}` at the **project root** or **`/src` root**:
53+
>
54+
> ```
55+
> /middleware.ts ✅
56+
> /src/middleware.ts ✅
57+
> /app/middleware.ts ❌ (not supported)
58+
> ```
59+
>
60+
> If the file is not at root, Next.js will not load it. See also: [Matcher config](https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher).
61+
5162
### Middleware function
5263
5364
The file must export a single function, either as a default export or named `middleware`. Note that multiple middleware from the same file are not supported.

0 commit comments

Comments
 (0)