Open History to see the last commit
1---
2id: EnvironmentManager
3title: environmentManager
4---
5β
6The `environmentManager` manages how TanStack Query detects whether the current runtime should be treated as server-side.
7β
8By default, it uses the same server detection as the exported `isServer` utility from query-core.
9β
10Use this manager to override server detection globally for runtimes that are not traditional browser/server environments (for example, extension workers).
11β
12Its available methods are:
13β
14- [`isServer`](#environmentmanagerisserver)
15- [`setIsServer`](#environmentmanagersetisserver)
16β
17## `environmentManager.isServer`
18β
19Returns whether the current runtime is treated as a server environment.
20β
21```tsx
22import { environmentManager } from '@tanstack/react-query'
23β
24const server = environmentManager.isServer()
25```
26β
27## `environmentManager.setIsServer`
28β
29Overrides the server check globally.
30β
31```tsx
32import { environmentManager } from '@tanstack/react-query'
33β
34// Override
35environmentManager.setIsServer(() => {
36 return typeof window === 'undefined' && !('chrome' in globalThis)
37})
38```
39β
40**Options**
41β
42- `isServerValue: () => boolean`
43β
44To restore the default behavior, set the function back to query-core's `isServer` utility:
45β
46```tsx
47import { environmentManager, isServer } from '@tanstack/react-query'
48β
49environmentManager.setIsServer(() => isServer)
50```