This package provides a type-safe integration of React Query with WunderGraph. React Query is a data fetching library for React. With just one hook, you can significantly simplify the data fetching logic in your project. And it also covered in all aspects of speed, correctness, and stability to help you build better experiences.
Before you can use the hooks, you need to modify your code generation to include the base typescript client.
Now you can configure the hooks. Create a new file, for example
lib/wundergraph.ts and add the following code:
App.tsx add QueryClientProvider:
Now you can use the hooks in your components:
useQuery (Live query)
You can use the
queryKey helper function to create a unique key for the query in a typesafe way. This is useful if you want to invalidate the query after mutating.