Skip to main content
For advanced data fetching needs, you can use the popular React Query library. It provides a powerful and flexible way to manage data fetching and caching for your application.

Example: Fetching stoic quotes with React Query

First, you create a server function to fetch a random stoic quote.
get-stoic-quote.server.ts
Then, you create an record action that will show a dialog. To use React Query, you wrap the dialog component in a QueryClientProvider and pass the queryClient to it.
stoic-quote.action.tsx
Finally, you create a quote component that will use the useSuspenseQuery hook to fetch the quote.
stoic-quote.tsx