R
fn

usePageLeave

v0.0.15testeddemo

Reactive flag indicating whether the mouse has left the page.

Examples

ts
const hasLeft = usePageLeave();
ts
usePageLeave({
  onChange: (isLeft) => {
    if (isLeft) showExitIntentModal();
  },
});

Demo

Loading demo…

Signature

ts
export function usePageLeave(options: UsePageLeaveOptions ={ ... }

Parameters

ParameterTypeDescription
options?UsePageLeaveOptionsOptions (custom `window`, `onChange` callback)

Returns

UsePageLeaveReturnWhether the pointer has left the page