Performance concern on Nextjs 13 layout files
Hello, I would like to ask the following questions regarding this code
First question would be, would you consider this a good solution to check whether the user would be an administrator? I know middleware is supposed to be a better candidate for a solution but I find layouts to be much easier.
Second question would be, given this file tree (attached screenshot) do you think there would be a potential issue whenever someone changes route? I think there should not be a problem due to caching but I am just looking for people with different opinions so I can improve my current arch.
Thanks for reading!
1 Reply
Regarding the second question, I would like to know if the database would perform the same query again and again on every redirect that the admin does. Inside the
isAdministrator
function lies a prisma call something like this