Prisma Adapter - Database Strategy - Reduce number of database calls #12209
Unanswered
joshmcqueen
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there! We successfully setup authjs with our nextjs react app. We're currently using AWS cognito provider, and everything looks good. Strategy is set to
database
.I think the issue stems from how we structured our app. For each major section in our app, we have a
actions.ts
file (server actions) anddata-access.ts
(SDKs, api calls....etc). To prevent abuse, we have to check if the user is authenticated at the beginning of every function inactions.ts
.This adds up over time. It's not uncommon for a page to call 10+ functions across various
actions.ts
files, and each time we're using auth() it makes a database call.example actions.ts:
On the client side, we are storing the session in the protected layout
but this only helps out on the client components. Is there a better approach to reduce the number of calls to the database from server components?
Beta Was this translation helpful? Give feedback.
All reactions