Composables

Introduction

Every nanime composable, and how they pick reactive or instant mode.

One composable per AnimeJS API, each with a live demo. For enter, leave and list animations, see the transition components.

useAnimate
Reactive wrapper for the animate function
useWaapiAnimate
Reactive wrapper for the waapi.animate function
useAnimatable
Wrapper for the createAnimatable function
useSplitText
Wrapper for the splitText utility
useScrambleText
Reactive wrapper for the scrambleText utility
useAnimeTimeline
Reactive wrapper for the createTimeline function
useDraggable
Wrapper for the createDraggable function
useAnimeScroll
Reactive wrapper for the onScroll function
useAnimeLayout
Wrapper for the createLayout function

When does an animation rebuild?

Composables run on the client only. Called in setup(), a composable rebuilds its animation when a ref, getter or reactive object it receives changes. The rebuild restarts the animation, unless keepTime: true carries the playhead over.

useAnimatable rebuilds only when its target changes, not its options.

Instant play

Composables marked

Instant play

also work outside setup(), for example in a click handler. There they build the animation once and read parameters a single time, so later ref changes are ignored. No warning is logged.

button.addEventListener('click', () => {
  // opacityRef changes after this call are ignored
  useAnimate('.box', () => ({ opacity: opacityRef.value }))
})

To keep reactivity, call the composable in setup() and call play() on the returned instance from the handler. A top-level await in <script setup> still counts as setup().

Buffered

Composables marked

Buffered

create their instance after mount. Methods that return the instance, like play(), can be called before then. nanime queues them and replays them in order once the instance exists. Other properties and methods read undefined until then.

useDraggable, useAnimeTimeline, useAnimeScroll and useAnimeLayout are buffered. useAnimeTimeline called outside setup() creates its instance at once.

Copyright © 2026