mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Closes: https://linear.app/vercel/issue/DOC-4686/clean-up-routing-section Redirects: https://github.com/vercel/front/pull/47151 --------- Co-authored-by: Joseph <[email protected]> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
51 lines
1.2 KiB
Plaintext
51 lines
1.2 KiB
Plaintext
---
|
|
title: forbidden.js
|
|
description: API reference for the forbidden.js special file.
|
|
related:
|
|
links:
|
|
- app/api-reference/functions/forbidden
|
|
version: experimental
|
|
---
|
|
|
|
The **forbidden** file is used to render UI when the [`forbidden`](/docs/app/api-reference/functions/forbidden) function is invoked during authentication. Along with allowing you to customize the UI, Next.js will return a `403` status code.
|
|
|
|
```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>
|
|
)
|
|
}
|
|
```
|
|
|
|
## Reference
|
|
|
|
### Props
|
|
|
|
`forbidden.js` components do not accept any props.
|
|
|
|
## Version History
|
|
|
|
| Version | Changes |
|
|
| --------- | -------------------------- |
|
|
| `v15.1.0` | `forbidden.js` introduced. |
|