---
title: "Vue without Nuxt"
description: "Use nanime in a Vue 3 app with no Nuxt module."
canonical_url: "https://nanimejs.netlify.app/guides/vue"
---
# 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

<code-group>

```bash [pnpm]
pnpm add nanime
```

```bash [npm]
npm install nanime
```

```bash [bun]
bun add nanime
```

</code-group>

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:

```ts [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`](https://nanimejs.netlify.app/guides/configuration#set-app-wide-options).

```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](https://nanimejs.netlify.app/guides/defaults) covers `components` and
`composables`, and [Presets](https://nanimejs.netlify.app/guides/presets) covers `preset`.

## Register the components and import the API

Register all three in the same `main.ts`:

```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:

```vue [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.

```ts [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:

```vue [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](https://nanimejs.netlify.app/guides/defaults#scope-defaults-to-part-of-the-app), with
`configureNanime()` taking the place of `app.config.ts`.


## Sitemap

See the full [sitemap](https://nanimejs.netlify.app/sitemap.md) for all pages.
