Better Auth is an open-source (MIT) TypeScript authentication library that runs inside your own app and stores users and sessions in your own database. With Next.js 16 you mount one route handler, cal

Markdown supported · ⌘↵ to post
Good point, thanks. In my test the page made one getSession() call and the proxy made another, so cache() wouldn't have changed the 4, but it matters as soon as a layout and a page (or a few server components) each check the session in the same render, since each call would otherwise cost 2 queries on Prisma 7. And yes, the proxy can't share that cache, which is one more reason to keep it as an optimistic redirect and do the real check in the page.
Tarun Sharma
React.js Frontend Web Developer | Next.js Specialist
The forged-cookie test is a good one to include. On the 4 queries per load: wrapping getSession in React's cache() inside one small data access function lets the layout, page and any server components in the same render share a single lookup. The proxy runs outside that render so it still pays its own, which is another reason to keep it to an optimistic redirect.