4 ms·
Re: why can't I access request: https://nextjs.org/docs/app#how-can-i-access-the-request-object-in-a-layout https://nextjs.org/docs/app#how-can-i-access-the-req
by leerob 2y ago
Re: why can't I access request: https://nextjs.org/docs/app#how-can-i-access-the-request-object-in-a-layout https://nextjs.org/docs/app#how-can-i-access-the-request-obj...
If filesystem routing isn't something you enjoy, Next.js probably isn't the right tool for you.
- hu3 2y ago> You intentionally cannot access the raw request object. However, you can access headers and cookies through server-only functions. You can also set cookies. > Layouts do not rerender. They can be cached and reused to avoid unnecessary computation when navigating between pages. By restricting layouts from accessing the raw request, Next.js can prevent the execution of potentially slow or expensive user code within the layout, which could negatively impact performance. I don't like this limiting "I know best what's good for you" attitude in my tooling. Yes limits are desirable to avoid footguns but this seems like too dumbed down of a restriction for little gain.
- citizenpaul 2y agoDo some people prefer using filesystem routing? I don't think I've used it before but it sounds clunky.