Next.js · Senior · Question 28 of 75
How do you connect forbidden() and unauthorized() to UI?
- ✓Correct answer: Enable
authInterruptsand addforbidden.tsx - 2They work out of the box and show the standard 404 page
- 3They're aliases of
redirect('/login')with a different HTTP status
Explanation
The functions interrupt rendering and show the corresponding UI with 403 and 401 statuses - similar to notFound(). It's an experimental feature for now. Redirecting to login is done separately, via redirect().