By default, Better Auth implements cookie caching (if you enable it in your config) to avoid unnecessary database calls; however, this is different from React’s per-request caching. In other words, server-side functions like auth.api.getSession aren’t automatically wrapped in React’s cache. If you’re using a framework like Next.js and want to avoid making multiple getSession calls within the same request, it’s a good idea to wrap the function with React’s cache() (as illustrated in [8]). This approach helps you reuse previously fetched values, further optimizing performance.
Is your feature request related to a problem? Please describe. import { betterAuth } from "better-auth"; const { api: { getSession, /* or any call */} } = betterAuth(...); ... await getSe...
Is your feature request related to a problem? Please describe. import { betterAuth } from "better-auth"; const { api: { getSession, /* or any call */} } = betterAuth(...); ... await getSe...
Hi there! I couldn’t find any details related to issue #781 or the referenced comment (3323836139) in our provided context documents. Could you please clarify which behavior or aspect of the issue you’re referring to? That way, I can check against our guidelines or known discussions regarding Better Auth and give you a more informed answer [1].
Not necessarily. While caching is a great optimization for reducing database queries for many read-only endpoints (like getting sessions or listing users) [1], you don’t need to wrap every single Better Auth server API call in cache(). For example, for endpoints that handle sensitive changes—such as password updates—the framework intentionally bypasses cookie caching to ensure you always get the most up-to-date session verification [4], [5]. In short, use caching where it helps performance without compromising security or data freshness.
Is this suited for github? Yes, this is suited for github Is your feature request related to a problem? Please describe. No response Describe the solution you'd like Auth functions like /change...