---
title: useBeforeUnload
---

# useBeforeUnload

[MODES: framework, data, declarative]

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.useBeforeUnload.html)

Setup a callback to be fired on the window's `beforeunload` event.

## Signature

```tsx
useBeforeUnload(callback, options): void
```

## Params

### callback

[modes: framework, data, declarative]

_No documentation_

### options

[modes: framework, data, declarative]

_No documentation_
