Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

hashKey.md

34 lines658 Bytes

1---
2id: hashKey
3title: hashKey
4---
5​
6```ts
7function hashKey(queryKey: readonly unknown[]): string;
8```
9​
10Defined in: [packages/query-core/src/utils.ts:323](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L323)
11​
12Default query & mutation keys hash function.
13Hashes the value into a stable hash.
14​
15## Parameters
16​
17### queryKey
18​
19readonly `unknown`[]
20​
21The query or mutation key to hash.
22​
23## Returns
24​
25`string`
26​
27The stable hash of the key, as a JSON string.
28​
29## Example
30​
31```ts
32// Object keys are sorted, so key order doesn't affect the hash:
33hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]'
34```