function useQueryClient(queryClient?: QueryClient): QueryClient;Defined in: packages/svelte-query/src/useQueryClient.ts:24
The useQueryClient function returns the current QueryClient instance.
Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
The current QueryClient instance.
If no queryClient argument is passed and no QueryClientProvider is found in the component tree.
<script lang="ts">
import { useQueryClient } from '@tanstack/svelte-query'
const queryClient = useQueryClient()
function refreshPosts() {
queryClient.invalidateQueries({ queryKey: ['posts'] })
}
</script>