Back

How to set up appwrite database caching using nextjs inbuild-caching ?

  • 0
  • Databases
  • Cloud
Booyah Squadians
1 Apr, 2025, 13:25

Hi everyone,I hope you're doing well.

I'm currently working on a project where I'm using Next.js for the frontend and Appwrite for the backend. I've been exploring ways to optimize performance, and I'm particularly interested in leveraging Next.js caching to improve efficiency. Specifically, I'm looking for guidance on how to effectively combine Next.js caching strategies (such as Incremental Static Regeneration or Server-Side Rendering) with data fetched from Appwrite.

I'm aware that Next.js provides built-in caching mechanisms, but I'm unsure about the best practices for integrating them with data fetched from an external source like Appwrite. If anyone has experience or insights into how to achieve this, I would greatly appreciate any advice, code examples, or resources you could share. Additionally, if there are any potential challenges or considerations I should be aware of, I'd love to hear about them. Thank you in advance for your help and support!

**TLDR: How to set up appwrite database caching using nextjs inbuild-caching ** (PS : i'm using the appwrite-node sdk as on my server side of nextjs , not the appwrite client side sdk)

TL;DR
null
Kenny
1 Apr, 2025, 13:27

Here is how I've done, it (https://github.com/dishwasher-detergent/appwrite-nextjs-starter/blob/main/lib/db/index.ts). Let me know if this is kinda what you were thinking, also let me know if you think this sucks haha

Booyah Squadians
1 Apr, 2025, 13:30

so in short you just wrap the entire call of databases in unstable_cache?

Kenny
1 Apr, 2025, 13:31

Most of the call, you wouldn't wrap auth checks, but yes, and in post/put/delete calls you invalidate the cache to prevent stale data

Booyah Squadians
1 Apr, 2025, 13:36

hmm what about other ways of doing it like using "use cache" n stuff?

Booyah Squadians
1 Apr, 2025, 13:36

cause in the docs they mention it would be replaced in future versions by "use cache"

Kenny
1 Apr, 2025, 13:47

You can try that out but afaik that's only available in canary releases of nextjs

Kenny
1 Apr, 2025, 13:47

so it's subject to a lot of change without notice.

D5
1 Apr, 2025, 14:11

Appwrite has too built-in mechanisms

D5
1 Apr, 2025, 14:11

But server sided, instead of client

Kenny
1 Apr, 2025, 14:24

Sure but if you use nextjs cache it caches closer to the user wheres appwrite does not :P

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more