0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-18 19:33:22 +00:00
query/docs/framework/svelte/reference/functions/useQueryClient.md
Wonsuk Choi f38e6271b4
chore(*): update '@tanstack/typedoc-config' to v0.3.5 (#12035)
* chore(scripts/generate-docs): read type alias bodies whose type parameters have defaults

* chore(*): update '@tanstack/typedoc-config' to v0.3.5
2026-10-17 11:14:03 +09:00

1 KiB

id title
useQueryClient useQueryClient
function useQueryClient(queryClient?: QueryClient): QueryClient;

Defined in: packages/svelte-query/src/useQueryClient.ts:24

The useQueryClient function returns the current QueryClient instance.

Parameters

queryClient?

QueryClient

Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.

Returns

QueryClient

The current QueryClient instance.

Throws

If no queryClient argument is passed and no QueryClientProvider is found in the component tree.

Example

<script lang="ts">
  import { useQueryClient } from '@tanstack/svelte-query'

  const queryClient = useQueryClient()

  function refreshPosts() {
    queryClient.invalidateQueries({ queryKey: ['posts'] })
  }
</script>