---
id: queries
title: Queries
ref: docs/framework/react/guides/queries.md
---
[//]: # 'SubscribeDescription'
To subscribe to a query in your components, call the `useQuery` function with at least:
[//]: # 'SubscribeDescription'
[//]: # 'Example'
```tsx
import { useQuery } from '@tanstack/solid-query'
function App() {
const todosQuery = useQuery(() => ({
queryKey: ['todos'],
queryFn: fetchTodoList,
}))
}
```
[//]: # 'Example'
[//]: # 'Example2'
```tsx
const todosQuery = useQuery(() => ({
queryKey: ['todos'],
queryFn: fetchTodoList,
}))
```
[//]: # 'Example2'
[//]: # 'Example3'
```tsx
import { Switch, Match, For } from 'solid-js'
function Todos() {
const todosQuery = useQuery(() => ({
queryKey: ['todos'],
queryFn: fetchTodoList,
}))
return (
Loading...
Error: {todosQuery.error.message}
)
}
```
[//]: # 'Example3'
[//]: # 'Example4'
```tsx
import { Switch, Match, For } from 'solid-js'
function Todos() {
const todosQuery = useQuery(() => ({
queryKey: ['todos'],
queryFn: fetchTodoList,
}))
return (
Loading...
Error: {todosQuery.error.message}
)
}
```
[//]: # 'Example4'
[//]: # 'Materials'
[//]: # 'Materials'