---
title: "Comment by Tarun Sharma on \"Better Auth with Next.js 16: proxy.ts, Prisma 7 and Server Actions (Tested Setup)\" | Hashnode"
description: "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 th"
url: "https://hashnode.com/posts/better-auth-nextjs-16/6adb85f3c414037f96346e1c/comment/6adda9a669bcac3dade7a361"
---

[Discussion](https://hashnode.com/posts/better-auth-nextjs-16/6adb85f3c414037f96346e1c)

Comment [Better Auth with Next.js 16: proxy.ts, Prisma 7 and Server Actions (Tested Setup)](https://hashnode.com/posts/better-auth-nextjs-16/6adb85f3c414037f96346e1c)

[Tarun Sharma](https://hashnode.com/@101beardo)

[Oct 25](https://hashnode.com/posts/better-auth-nextjs-16/6adb85f3c414037f96346e1c/comment/6adda9a669bcac3dade7a361)

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.

[Waseem Anjum](https://hashnode.com/@fabwaseem)

[Oct 25](https://hashnode.com/posts/better-auth-nextjs-16/6adb85f3c414037f96346e1c/comment/6adda9a669bcac3dade7a361#reply-6adde41e31fdbe9f7258cd75)

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.
