File: onlineManager.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
React
Version
v4
Search...
+ K
Menu
Getting Started
Guides & Concepts
Community Resources
API Reference
ESLint
Plugins
Examples
Framework
React
Version
v4
Menu
Getting Started
Guides & Concepts
Community Resources
API Reference
ESLint
Plugins
Examples
On this page
Copy Markdown
The OnlineManager manages the online state within TanStack Query.
It can be used to change the default event listeners or to manually change the online state.
Its available methods are:
onlineManager.setEventListener
------------------------------
setEventListener can be used to set a custom event listener:
tsx
import NetInfo from '@react-native-community/netinfo'
import { onlineManager } from '@tanstack/react-query'
onlineManager.setEventListener(setOnline => {
return NetInfo.addEventListener(state => {
setOnline(!!state.isConnected)
})
})
import NetInfo from '@react-native-community/netinfo'
import { onlineManager } from '@tanstack/react-query'
onlineManager.setEventListener(setOnline => {
return NetInfo.addEventListener(state => {
setOnline(!!state.isConnected)
})
})
onlineManager.setOnline
-----------------------
setOnline can be used to manually set the online state. Set undefined to fallback to the default online check.
tsx
import { onlineManager } from '@tanstack/react-query'
// Set to online
onlineManager.setOnline(true)
// Set to offline
onlineManager.setOnline(false)
// Fallback to the default online check
onlineManager.setOnline(undefined)
import { onlineManager } from '@tanstack/react-query'
// Set to online
onlineManager.setOnline(true)
// Set to offline
onlineManager.setOnline(false)
// Fallback to the default online check
onlineManager.setOnline(undefined)
Options
onlineManager.isOnline
----------------------
isOnline can be used to get the current online state.
tsx
const isOnline = onlineManager.isOnline()
const isOnline = onlineManager.isOnline()
[###### Want to Skip the Docs?
Query.gg - The Official React Query Course
\
“If you’re serious about *really* understanding React Query, there’s no better way than with query.gg”—Tanner Linsley
Learn More](https://query.gg/?s=tanstack)
You are currently reading v4 docs. Redirect to latest version?
Latest Hide
