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

hashKey.md

36 lines731 Bytes

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