Capítulo 199 de 456

authInterrupts

Core Idea

Experimental config flag required to use the forbidden() and unauthorized() APIs in your app. Currently canary-channel and subject to change.

Key Concepts

  • experimental.authInterrupts: Deve ser true para habilitar forbidden e unauthorized.

Code Examples

import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    authInterrupts: true,
  },
}

export default nextConfig
  • O que demonstra: Habilitação mínima do flag para desbloquear as duas APIs de interrupção de auth.

Key Takeaways

  1. Requer versão canary do Next.js.
  2. Sem este flag, forbidden() e unauthorized() não funcionam.
  3. Existem arquivos convencionais correspondentes: forbidden.js e unauthorized.js, para renderizar UI de erro nesses cenários.

Connects To

  • forbidden() / unauthorized(): funções que este flag desbloqueia.
  • forbidden.js / unauthorized.js: arquivos de convenção para as telas de erro correspondentes.