Guides

Vue without Nuxt

Use nanime in a Vue 3 app with no Nuxt module.

nanime/vue is a second entry point for Vue 3 apps built without Nuxt. It exports the composables, the three components, and everything the #nanime/* aliases give a Nuxt app: types, easings, utilities and proxies. configureNanime() sets the app-wide config that a Nuxt app reads from app.config.ts and nuxt.config.ts.

Install the package

pnpm add nanime

Without Nuxt there are no auto-imports and no #nanime/* aliases. Import everything from nanime/vue and register each component by hand.

Pre-bundle the AnimeJS submodules

The Nuxt module pre-bundles the animejs/* submodules it imports. In a plain Vite app, list the ones you use under optimizeDeps.include so Vite does not reload the page when they first load:

vite.config.ts
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    include: [
      'animejs/animation',
      'animejs/layout',
      'animejs/timeline',
      'animejs/text',
      'animejs/utils',
    ],
  },
})

Configure the app

Call configureNanime() on the app before it mounts. The config has the same shape as the nanime key in app.config.ts.

main.ts
import { createApp } from 'vue'
import { configureNanime } from 'nanime/vue'
import App from './App.vue'

const app = createApp(App)

configureNanime(app, {
  reducedMotion: 'system',
  components: {
    transition: { enterAnimation: 'slide-up', mode: 'out-in' },
  },
  composables: {
    animate: { duration: 600, ease: 'out(3)' },
  },
})

app.mount('#app')

Pass a ref or getter as the second argument when the config changes at runtime. Defaults covers components and composables, and Presets covers preset.

Register the components and import the API

Register all three in the same main.ts:

main.ts
import { AnimeLayoutGroup, AnimeTransition, AnimeTransitionGroup } from 'nanime/vue'

app.component('AnimeTransition', AnimeTransition)
app.component('AnimeTransitionGroup', AnimeTransitionGroup)
app.component('AnimeLayoutGroup', AnimeLayoutGroup)

Or import one in the component that uses it:

App.vue
<script setup lang="ts">
import { AnimeTransition } from 'nanime/vue'
</script>

<template>
  <AnimeTransition>
    <div v-if="show" />
  </AnimeTransition>
</template>

The nanime/vue entry imports the components' stylesheet, so there is no stylesheet to import.

Import the rest of the API

Every other export also comes from nanime/vue:

  • The easings, utilities and proxies that Nuxt exposes as #nanime/* aliases.
  • The public types.
  • The animate and createTimer functions.
main.ts
import { animate, morphTo, stagger } from 'nanime/vue'
import type { NanimeConfig } from 'nanime/vue'

Scope defaults to part of the app

provideAnimeDefaults() works in any component. It sets defaults for the components and composables inside that component:

SettingsPanel.vue
<script setup lang="ts">
import { provideAnimeDefaults } from 'nanime/vue'

provideAnimeDefaults({
  composables: { animate: { duration: 300 } },
  transition: { enterAnimation: 'scale' },
})
</script>

Scoping works as described in Defaults, with configureNanime() taking the place of app.config.ts.

Copyright © 2026