Composables

Introduction

Explore the available composables in nanime.

nanime provides a set of composables that wraps AnimeJS utilities.

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

Instant play

Composables marked with the Instant play badge can be called after mount, from an event handler or a utility function, not only from setup(). They pick their mode from whether getCurrentInstance() returns an instance when they run:

  • Reactive mode, with an instance. Target and parameters are watched, so a ref or getter that changes reverts the animation and builds a new one.
  • Instant mode, without one. The animation is created once and parameters are read a single time, even if you pass a ref.

Top-level await in <script setup> keeps reactive mode, because the compiler wraps it in withAsyncContext() and the instance is restored once the promise settles. Event handlers, onMounted, watchers, setTimeout, awaits inside a nested async function and a plain Options API async setup() all run without one.

// instant: deferred past setup(), no instance to find
onMounted(() => {
  const anim = useAnimate('.box', () => ({ opacity: opacityRef.value }))
  // opacityRef changes are now ignored
})
You will not get a warning, and the animation still runs. Only the reactivity is lost. To keep it while still triggering the animation later, call the composable in setup() and drive it through the instance it returns.

useDraggable and useSplitText don't use this flag. They stay reactive whatever the call context, so there is no instant mode to fall into.

Copyright © 2026