next
Version:
The React Framework
53 lines (41 loc) • 1.43 kB
Markdown
---
title: forbidden.js
description: API reference for the forbidden.js special file.
related:
links:
- app/api-reference/functions/forbidden
version: experimental
---
The **forbidden** file renders UI when the [`forbidden`](/docs/app/api-reference/functions/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](/docs/app/api-reference/file-conventions/loading
```tsx filename="app/forbidden.tsx" switcher
import Link from 'next/link'
export default function Forbidden() {
return (
<div>
<h2>Forbidden</h2>
<p>You are not authorized to access this resource.</p>
<Link href="/">Return Home</Link>
</div>
)
}
```
```jsx filename="app/forbidden.jsx" switcher
import Link from 'next/link'
export default function Forbidden() {
return (
<div>
<h2>Forbidden</h2>
<p>You are not authorized to access this resource.</p>
<Link href="/">Return Home</Link>
</div>
)
}
```
`forbidden.js` components do not accept any props.
| Version | Changes |
| --------- | -------------------------- |
| `v15.1.0` | `forbidden.js` introduced. |