Next.js Discord

Discord Forum

Nextjs Caching trpc / drizzle

Unanswered
Nile perch posted this in #help-forum
Open in Discord
Nile perchOP
Im using trpc for a mutation ie inserting some data into my db. And then im fetching it directly with drizzle in my page. Is this a bad idea? I seem to be getting stale data.

13 Replies

I dont think its a bad idea, I just think you need to tell it to not cache
when you build does it build the page as static?
@Jboncz I dont think its a bad idea, I just think you need to tell it to not cache
Nile perchOP
I want it to cache though
Uhhhh, then how do you plan on getting current data?
Sorry, that was a silly comment, I mean how do you plan on telling it when you want it to invalidate the cache?
Nile perchOP
Oh right i think i can just revalidatePath in my trpc handler
I was assuming it only worked for server actions
Nah. I dont use trpc, but im assuming itll work.
If you want more help, you gotta share the relevant code so I can take a look.
Nile perchOP
It worked no worries. Thanks.
Nice! Mark the answer so the thread closes. GJ fixing it 🙂
Please Ping me when you reply.