useDocumentLeave

Tags:

A React Hook that tracks whether the user is leaving the document.

Demo

Try to move your mouse outside the browser viewport to check.

Source
Is user leave page:
false
欢迎回来!(≧◡≦) ♡
おかえりなさい!(≧◡≦) ♡
Welcome back! (≧◡≦) ♡

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const isDocumentLeave = useDocumentLeave()

Returns

A boolean value that indicates whether the user is leaving the document or not.