[TanStack Start] How does one invalidate specific server functions (in between components)? #3474
-
Hi, Let's say we have two components. One of them calls a server function that has a side effect of creating a notification. Notifications are displayed by a different component (in the navbar, for example). How do I invalidate the notifications server function call from within the component that triggers the handler with the side effect of adding a notification? I know that tRPC and TanStack Query offer this sort of functionality, but how can I achieve it with server functions? See my example below. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
if you call the server function from a component, there is nothing to invalidate. nothing is cached. I might be misunderstanding your question, so an actual example would be helpful. |
Beta Was this translation helpful? Give feedback.
when called in components, you would need to call again. a server function is just ... a function. it does not have state. you handle this. or just use query to call it and then you can invalidate via query