React AnimeJS

Timer

coreBeginnerRead the docs

Code

1const { controls, state, isRunning } = useAnimeTimer({
2 duration: 1000,
3 loop: true,
4 autoplay: true, // start immediately; pause/restart via controls
5 frameRate: 30,
6})

Standalone timer with playback controls, lifecycle callbacks, and imperative methods.

Live preview
Standalone TimerLooping timer with playback controls
Time0
Progress0%
Iteration0
Props
NameTypeDefaultDescription
durationnumber1000Timer duration in ms
loopnumber | booleanfalseLoop count or infinite
directionstringnormalnormal | alternate | reverse
frameRatenumber60Update frame rate
autoplaybooleanfalseStart on mount
controls.playfunction-Start/resume playback
controls.pausefunction-Pause playback
controls.restartfunction-Restart timer
state.currentTimenumber-Elapsed ms
state.progressnumber-Current progress 0→1
state.currentIterationnumber-Loop iteration count

Related components