@reduxjs/toolkit
Version:
The official, opinionated, batteries-included toolset for efficient Redux development
13 lines (12 loc) • 428 B
text/typescript
/**
* Assumes a browser is online if `undefined`, otherwise makes a best effort
* @link https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
*/
export function isOnline() {
// We set the default config value in the store, so we'd need to check for this in a SSR env
return typeof navigator === 'undefined'
? true
: navigator.onLine === undefined
? true
: navigator.onLine
}