# useTanstackQueryStableQueryClient

Rule `biome/useTanstackQueryStableQueryClient`. Require the TanStack Query `QueryClient` to be created once, not on every render.

- Source: biome
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 30.6M weekly downloads of presets that enable it
- Trend: +109.3% last quarter
- Rank: #618 by reach, #253 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Biome | `nursery/useTanstackQueryStableQueryClient` | yes | unsafe | group nursery, since 2.6.5 | [docs](https://biomejs.dev/linter/rules/use-tanstack-query-stable-query-client/) |

## Code examples

### Incorrect: the rule reports this

```jsx
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

function App() {
    const queryClient = new QueryClient();
    return (
        <QueryClientProvider client={queryClient}>
            <Home />
        </QueryClientProvider>
    );
}
```

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

const useQueryClient = () => {
    const queryClient = new QueryClient();
    return queryClient;
};
```

### Correct: the rule accepts this

```jsx
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useState } from "react";

const sharedClient = new QueryClient();

function App() {
    const [queryClient] = useState(() => new QueryClient());
    return (
        <QueryClientProvider client={queryClient}>
            <Home />
        </QueryClientProvider>
    );
}

async function ServerComponent() {
    const queryClient = new QueryClient();
    await queryClient.prefetchQuery(options);
}
```

Examples from the Biome documentation.

## Enable it

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useTanstackQueryStableQueryClient": "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/useTanstackQueryQueryOptions](https://lintradar.dev/rules/biome/useTanstackQueryQueryOptions.md): Require TanStack Query options to be created with `queryOptions()`.
- [biome/noImportantStyles](https://lintradar.dev/rules/biome/noImportantStyles.md): Disallow `!important` declarations.
- [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/noPrivateImports](https://lintradar.dev/rules/biome/noPrivateImports.md): Restrict imports of private exports.
- [biome/useTanstackQueryInfiniteQueryPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryInfiniteQueryPropertyOrder.md): Enforce a consistent property order in the options of TanStack Query infinite query functions.
- [biome/noUndeclaredEnvVars](https://lintradar.dev/rules/biome/noUndeclaredEnvVars.md): Disallow the use of undeclared environment variables.

---

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