# useTanstackQueryQueryOptions

Rule `biome/useTanstackQueryQueryOptions`. Require TanStack Query options to be created with `queryOptions()`.

- Source: biome
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 30.6M weekly downloads of presets that enable it
- Trend: +109.3% last quarter
- Rank: #617 by reach, #252 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Biome | `nursery/useTanstackQueryQueryOptions` | yes | no | group nursery, since 2.6.10 | [docs](https://biomejs.dev/linter/rules/use-tanstack-query-query-options/) |

## Code examples

### Incorrect: the rule reports this

```js
import { useQuery } from "@tanstack/react-query";

function Todo({ id }) {
    const query = useQuery({
        queryKey: ["todo", id],
        queryFn: () => fetchTodo(id),
    });
}
```

```js
import { useQueries } from "@tanstack/react-query";

function Dashboard() {
    const results = useQueries({
        queries: [{ queryKey: ["todos"], queryFn: fetchTodos }, userOptions],
    });
}
```

```js
import { useQueryClient } from "@tanstack/react-query";

function useCachedTodo(id) {
    const queryClient = useQueryClient();
    return queryClient.getQueryData(["todo", id]);
}
```

### Correct: the rule accepts this

```js
import { queryOptions, useQuery, useQueryClient } from "@tanstack/react-query";

function todoOptions(id) {
    return queryOptions({
        queryKey: ["todo", id],
        queryFn: () => fetchTodo(id),
    });
}

function Todo({ id }) {
    const query = useQuery(todoOptions(id));
    const title = useQuery({ ...todoOptions(id), select: (todo) => todo.title });
}

function useRefreshTodo(id) {
    const queryClient = useQueryClient();
    const cached = queryClient.getQueryData(todoOptions(id).queryKey);
    return () => queryClient.invalidateQueries({ queryKey: todoOptions(id).queryKey });
}
```

Examples from the Biome documentation.

## Enable it

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useTanstackQueryQueryOptions": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [biome/useTanstackQueryMutationPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryMutationPropertyOrder.md): Enforce that `onMutate` comes before `onError` and `onSettled` in the options of TanStack Query mutations.
- [biome/useTanstackQueryStableQueryClient](https://lintradar.dev/rules/biome/useTanstackQueryStableQueryClient.md): Require the TanStack Query `QueryClient` to be created once, not on every render.
- [biome/useTanstackQueryInfiniteQueryPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryInfiniteQueryPropertyOrder.md): Enforce a consistent property order in the options of TanStack Query infinite query functions.
- [biome/noImportantStyles](https://lintradar.dev/rules/biome/noImportantStyles.md): Disallow `!important` declarations.
- [biome/useTanstackQueryExhaustiveDependencies](https://lintradar.dev/rules/biome/useTanstackQueryExhaustiveDependencies.md): Require query keys to include every value that the query function uses.
- [biome/noPrivateImports](https://lintradar.dev/rules/biome/noPrivateImports.md): Restrict imports of private exports.

---

Web page: https://lintradar.dev/rules/biome/useTanstackQueryQueryOptions. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
