useTimerTrigger
Fires after a fixed delay. Pass onOpenChange to wire it to your popup's open state. The timer starts on mount and calls onOpenChange(true) once after ms milliseconds.
$import { useTimerTrigger } from react-marketing-popups
Signature
useTimerTrigger({ ms?, onOpenChange? })
Returns
readonly [boolean, Dispatch<SetStateAction<boolean>>]Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| ms | number | 3000 | Milliseconds to wait before the trigger fires |
| onOpenChange | (v: boolean) => void | — | Called with true when the timer fires. Wire to your popup's open state setter. |
Returns
fired
boolean — whether the timer has fired. Starts as false, becomes true after the delay elapses.setFired
Dispatch<SetStateAction<boolean>> — rarely needed directly; the hook manages this internally. Use a separate useState for popup visibility.Code Examples
By design the open state is handled outside of the component
Basic usage
Pass onOpenChange to set your open state when the timer fires. Manage popup visibility separately with useState.
Loading...Combined with usePersistence
Pair with usePersistence to show the popup only once — even across page reloads.
Loading...