useOnline#

Reactive navigator.onLine via the online/offline events. Browser composable — import from @sigx/use-web.

TypeScript
import { effect } from 'sigx';
import { useOnline } from '@sigx/use-web';

const online = useOnline();
effect(() => { if (!online.value) showOfflineBanner(); });

This is the sugar form of the cross-platform connectivity contract — useOnline() is useNetwork().isConnected as a standalone ReadSignal<boolean>. Reach for useNetwork when you also need type or the Network Information API extras.

Signature#

TypeScript
function useOnline(options?: ConfigurableWindow): ReadSignal<boolean>;

Pass { window } to drive it from a mock — see Configurable*.

SSR#

On the server the signal reads true, then reflects navigator.onLine on mount.

See also#