Next.js Discord

Discord Forum

getting data through pocket-base sdk

Answered
Scale parasitoid posted this in #help-forum
Open in Discord
Scale parasitoidOP
is it cached like how nextjs caches its "fetch"? if not how do i force it to be only evaluated at build time.
It is somewhat cached, but if i refresh the browser 2 times or more, it busts the cache, and i can see pocketbase logging that nextjs indeed revalidated.
Answered by Ray
it is not caching the result last time I tried so I have to wrap the function with unstable_cache
View full answer

11 Replies

@Ray try passing the cache option to it ts pb.collection("posts").getList(page, perPage, { sort: "-created", cache: "no-store", })
Scale parasitoidOP
hey thanks for replying! 🙂 but is it possible to mimic ssg in rsc? if i understood your suggestion correctly, vercel will still fetch to my pocketbase instance dynamically
Scale parasitoidOP
i understand that using fetch will do this automatically, but alas, im too deep into the sdk before realizing this
the sdk use fetch under the hood
you could verfiy it by go to .next/cache/fetch-cache
@Ray the sdk use fetch under the hood
Scale parasitoidOP
yeah but i think nextjs hijacks fetch, but thanks i'll try your suggestion, thanks!
@Scale parasitoid yeah but i think nextjs hijacks fetch, but thanks i'll try your suggestion, thanks!
it is not caching the result last time I tried so I have to wrap the function with unstable_cache
Answer
@Ray it is not caching the result last time I tried so I have to wrap the function with `unstable_cache`
Scale parasitoidOP
it's working! thanks! i tried cache from react earlier, wasnt aware that there's unstable_cache from next/cache. thanks Ray!