Refetching/revalidating server query with TRPC
[Nextjs 14 app Dir]
Hello, i want to revalidate my query after form sumit but for some reason i dont know what am i doing wrong. As im newbie in trpc i want to just revalidate specified request "onSuccess" after mutation but it doesnt work.
Thats the code:
Here im fetching card of user (with .query),
then im passing it to CardStylesStoreProvider where im creating zustand store with that:
Lastly onsubmit im updating my DB with data and want to revalidate this previous request but for some reason it doesnt work.. When i change route and back im getting old state (it only works on total F5 reload)
7 Replies
Idk where im getting wrong :/
as this satte is kind of dehydrated SSR state so i should be able to refetch that, riht?
I can do just "router.refresh()" but its kinda... workaround, not solution
I'm working on this issue as well. @Bartholomeas did you ever find a solution other than
router.refresh
?Still not :/
I'm sure you've seen
revalidatePath
, which would be helpful if TRPC ever implemented something like this.
https://nextjs.org/docs/app/api-reference/functions/revalidatePath
I haven't been able to make it work with TRPC though :/i've had this response from my older question but hmm.. Looks not best idea
![No description](https://cdn.answeroverflow.com/1228597016217522246/Zrzut_ekranu_2024-04-13_o_08.45.36.png)
i mean there is no way to revalidate single request? 😐
So one awesome function of nextjs is not handled by trpc?
@Matvey Sorry for ping but similar question; maybe you know somethinf more? 😄
Yea shades of the same issue - I have found no documentation online for how to handle trpc endpoint cacheing/revalidation with Next Ap Router https://discord.com/channels/966627436387266600/1212328159991570452/1212328159991570452 & https://discord.com/channels/966627436387266600/1228337408563740803