mirror of
https://github.com/TanStack/query.git
synced 2026-11-16 22:50:20 +00:00
1.3 KiB
1.3 KiB
| id | title |
|---|---|
| EnvironmentManager | environmentManager |
The environmentManager manages how TanStack Query detects whether the current runtime should be treated as server-side.
By default, it uses the same server detection as the exported isServer utility from query-core.
Use this manager to override server detection globally for runtimes that are not traditional browser/server environments (for example, extension workers).
Its available methods are:
environmentManager.isServer
Returns whether the current runtime is treated as a server environment.
import { environmentManager } from '@tanstack/react-query'
const server = environmentManager.isServer()
environmentManager.setIsServer
Overrides the server check globally.
import { environmentManager } from '@tanstack/react-query'
// Override
environmentManager.setIsServer(() => {
return typeof window === 'undefined' && !('chrome' in globalThis)
})
Options
isServerValue: () => boolean
To restore the default behavior, set the function back to query-core's isServer utility:
import { environmentManager, isServer } from '@tanstack/react-query'
environmentManager.setIsServer(() => isServer)