R
fn

useDocumentReadyState

v0.0.15testeddemo

Reactive `document.readyState` (`loading` | `interactive` | `complete`), updated on `readystatechange`.

Examples

ts
const readyState = useDocumentReadyState();
watch(readyState, (state) => {
  if (state === 'complete') runAfterLoad();
});
ts
useDocumentReadyState({
  onChange: (state) => {
    if (state === 'interactive') hydrate();
  },
});

Demo

Loading demo…

Signature

ts
export function useDocumentReadyState(
  options: UseDocumentReadyStateOptions ={ ... }

Parameters

ParameterTypeDescription
options?UseDocumentReadyStateOptionsOptions (custom `document`, `onChange` callback)

Returns

UseDocumentReadyStateReturnThe current document ready state