Next.js · Senior · Question 32 of 75

Why shouldn't a layout be the only place where authorization is checked?

Explanation

Thanks to partial rendering, a shared layout doesn't run again during navigation within a segment, so a check in it may not fire. Besides, Route Handlers and Server Actions are reachable directly. Keep checks close to the data - in the Data Access Layer, pages and actions.

Further reading

Problem with a question

Next.js · Senior · question 32

Test yourself

Take the Next.js · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz