Open History to see the last commit
1---
2id: environmentManager
3title: environmentManager
4redirect_from:
5 - reference/environmentManager
6---
7β
8<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
9β
10```ts
11const environmentManager: object;
12```
13β
14Defined in: [packages/query-core/src/environmentManager.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L32)
15β
16Manages how TanStack Query detects whether the current runtime should be treated as
17server-side, which disables scheduling refetch timers and changes the default `retry` count
18and `gcTime`. By default, the detection treats a missing `window` (or the presence of a
19`Deno` global) as server.
20β
21Override this for runtimes where that default detection would give the wrong answer β for
22example, a Service Worker, where `window` is undefined even though the environment should
23behave like a client.
24β
25## Type Declaration
26β
27### isServer
28β
29```ts
30isServer: () => boolean;
31```
32β
33Returns whether the current runtime should be treated as a server environment.
34β
35#### Returns
36β
37`boolean`
38β
39`true` if the runtime is treated as a server.
40β
41### setIsServer()
42β
43```ts
44setIsServer(isServerValue: IsServerValue): void;
45```
46β
47Overrides the server check globally.
48β
49#### Parameters
50β
51##### isServerValue
52β
53`IsServerValue`
54β
55A function that returns whether the runtime should be treated as a
56server.
57β
58#### Returns
59β
60`void`
61β
62## Example
63β
64```ts
65import { environmentManager } from '@tanstack/query-core'
66β
67environmentManager.setIsServer(() => false)
68```