Any better way for data refreshing here?
https://github.com/LockScript/lockscript-vault/blob/main/src/app/(main)/page.tsx
https://github.com/LockScript/lockscript-vault/blob/main/src/components/vault/vault-page.tsx#L67
GitHub
lockscript-vault/src/app/(main)/page.tsx at main · LockScript/locks...
Contribute to LockScript/lockscript-vault development by creating an account on GitHub.
GitHub
lockscript-vault/src/components/vault/vault-page.tsx at main · Lock...
Contribute to LockScript/lockscript-vault development by creating an account on GitHub.
4 Replies
You opted for speed from this bot. Let's conjure up an answer right now!
Based on the provided knowledge sources and your question about data refreshing in a Next.js application using Prisma, I can suggest a few improvements:
1. Use Stale-While-Revalidate (SWR) strategy:
Instead of using
revalidate
, you can implement the SWR strategy provided by Prisma Accelerate. This allows you to serve cached data while fetching fresh data in the background.
Prisma Docs: Stale-While-Revalidate (SWR)
2. Implement on-demand cache invalidation:
For real-time or near-real-time data updates, you can use cache invalidation to bypass extended caching periods and show live data when needed.
Prisma Docs: Invalidate the SWR
3. Use Next.js Server Actions:
Instead of creating API routes, you can use Server Actions for easier integration with Prisma and better type safety. This approach can be more efficient for data fetching and updates.
Github Issue: Next.js 13+ caching prevents fetching of updated data
Remember that some of these features, like on-demand cache invalidation, are available with Prisma Accelerate paid plans. Make sure to check the pricing and features that best suit your needs.
These approaches should provide better data refreshing strategies for your Next.js application using Prisma. They offer more control over caching and data freshness compared to the current implementation in your GitHub repository.
🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.Alright
Can you elaborate on what specific part of your code you want feedback on?
Are you referring to getPasswords method?
i mainly mean displaying fresh data after performing updates through prisma, as some fields just update weirdly or need a reload.