0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
query/docs/reference/environmentManager.md
Dominik Dorfmeister 🔮 6fa901b97a
feat/environmentManager (#10199)
* environmentManager

* ci: apply automated fixes

* ref: environmentManager

* fix: adapt tests to not using isServer anymore

* ref: revert to main

* make tests better

* Create moody-mails-deliver.md

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-03-18 12:52:51 +01:00

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)