react-code-dataset
/
next.js
/docs
/01-app
/03-api-reference
/05-config
/01-next-config-js
/authInterrupts.mdx
| title: authInterrupts | |
| description: Learn how to enable the experimental `authInterrupts` configuration option to use `forbidden` and `unauthorized`. | |
| version: canary | |
| related: | |
| links: | |
| - app/api-reference/functions/forbidden | |
| - app/api-reference/functions/unauthorized | |
| - app/api-reference/file-conventions/forbidden | |
| - app/api-reference/file-conventions/unauthorized | |
| The `authInterrupts` configuration option allows you to use [`forbidden`](/docs/app/api-reference/functions/forbidden) and [`unauthorized`](/docs/app/api-reference/functions/unauthorized) APIs in your application. While these functions are experimental, you must enable the `authInterrupts` option in your `next.config.js` file to use them: | |
| ```ts filename="next.config.ts" switcher | |
| import type { NextConfig } from 'next' | |
| const nextConfig: NextConfig = { | |
| experimental: { | |
| authInterrupts: true, | |
| }, | |
| } | |
| export default nextConfig | |
| ``` | |
| ```js filename="next.config.js" switcher | |
| module.exports = { | |
| experimental: { | |
| authInterrupts: true, | |
| }, | |
| } | |
| ``` | |