Visitar URL original
File-system conventions: forbidden.js | Next.js
Skip to content
This page is also available as Markdown: request this page's URL with an Accept: text/markdown header. For an index of Next.js documentation, see /docs/llms.txt.

forbidden.js

This feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.
Last updated October 6, 2026

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.

app/forbidden.tsx
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

VersionChanges
v15.1.0forbidden.js introduced.

Was this helpful?

supported.