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:
Returns whether the current runtime is treated as a server environment.
import { environmentManager } from '@tanstack/react-query'
const server = environmentManager.isServer()
Overrides the server check globally.
import { environmentManager } from '@tanstack/react-query'
// Override
environmentManager.setIsServer(() => {
return typeof window === 'undefined' && !('chrome' in globalThis)
})
Options
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)