Open History to see the last commit
1---
2id: QueryObserver
3title: QueryObserver
4---
5β
6## `QueryObserver`
7β
8The `QueryObserver` can be used to observe and switch between queries.
9β
10```js
11const observer = new QueryObserver(queryClient, { queryKey: ['posts'] })
12β
13const unsubscribe = observer.subscribe(result => {
14 console.log(result)
15 unsubscribe()
16})
17```
18β
19**Options**
20β
21The options for the `QueryObserver` are exactly the same as those of [`useQuery`](/reference/useQuery).