forbidden.js
The forbidden file renders UI when the forbidden function is invoked.
Before streaming starts, Next.js returns a 403 status code. After streaming starts, the status code remains 200 and the forbidden UI renders in the response. Next.js injects a <meta name="robots" content="noindex" /> tag in both cases. See Status codes for details.
Reference
Props
forbidden.js components do not accept any props.
Good to know
Next.js sends each forbidden.js file with every route under its segment, even when forbidden() is never called, and loads the Client Components it imports on those pages. Prefer Server Components and <Link> there over interactive UI.
Version History
| Version | Changes |
|---|---|
v15.1.0 | forbidden.js introduced. |
Last updated