Skip to main content

useBeforeUnload

useBeforeUnload

Framework Data Declarative

Summary

Reference Documentation ↗

Set up a callback to be fired on Window's beforeunload event.

Signature

function useBeforeUnload(
  callback: (event: BeforeUnloadEvent) => any,
  options?: {
    capture?: boolean;
  },
): void

Params

callback

The callback to be called when the beforeunload event is fired.

options.capture

If true, the event will be captured during the capture phase. Defaults to false.

Returns

No return value.

Translation © 2026 fanyi.dev · Original © 2026 React Training LLC, Remix Software Inc., Shopify Inc. (MIT)