Next.js Discord

Discord Forum

Slow Fetching problem

Unanswered
Axus posted this in #help-forum
Open in Discord
Hi

I'm currently working on a project, and I'm facing issues with slow fetch performance. Specifically, when I execute the handleUpdateHabit function, the fetching process takes around 7-10 seconds, which is affecting the overall user experience.

Here are some details about the setup:

I'm using Prisma as my ORM.
The handleUpdateHabit function is updating a habit, creating logs, and refreshing habit metrics (handleHabitMetrics), which includes consistency rate, streaks, and missed days calculations.
For fetching, I use Next.js (client/server components), Clerk for user authentication, and react-hot-toast for notifications.
Does anyone have recommendations to drastically reduce the fetch time or optimize the performance of this process? I'm open to both backend and frontend solutions, and any ideas or tips would be greatly appreciated.

HabitDisplay in attachment
useHabit.tsx in attachement (custom hook)
actionHabit.ts (all functions used)

Thank you in advance for your help! I tried so many thing, i don't know what to do.

1 Reply

habitDIsplay.tsx