UNPKG

432 BPlain TextView Raw
1/**
2 * Assumes a browser is online if `undefined`, otherwise makes a best effort
3 * @link https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
4 */
5export function isOnline() {
6 // We set the default config value in the store, so we'd need to check for this in a SSR env
7 return typeof navigator === 'undefined'
8 ? true
9 : navigator.onLine === undefined
10 ? true
11 : navigator.onLine
12}