useWindowFocus
Tracks whether the browser window currently has focus as a reactive Observable<boolean>.
Updates automatically when the user switches tabs, clicks away, or returns to the window.
SSR-safe: returns false when document is not available.
focused$.get() = false
Click outside this window or switch tabs to see the value change.
import { useWindowFocus } from "@usels/core";
function Component() { const focused$ = useWindowFocus();
return <p>Window is {focused$.get() ? "focused" : "blurred"}</p>;}Pausing work when the window loses focus
Section titled “Pausing work when the window loses focus”const focused$ = useWindowFocus();
useObserve(() => { if (!focused$.get()) pausePolling(); else resumePolling();});Type Declarations
Section titled “Type Declarations”export declare function useWindowFocus(): Observable<boolean>;Source
Section titled “Source”Contributors
Section titled “Contributors”- tigerwest
Changelog
Section titled “Changelog”a7392ab2026-03-06 - feat(core,browser): add sync strategy hooks (tigerwest)