Skip to content

Commit 6d760c1

Browse files
ryo-manbaclaude
andcommitted
docs: add Vue and Nuxt integration guides, fix Next.js SSR import
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 42a9489 commit 6d760c1

1 file changed

Lines changed: 52 additions & 2 deletions

File tree

docs/src/pages/docs/integration.mdx

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ data-anim works with any HTML-based project. Since it uses HTML attributes and i
1414

1515
- [Static HTML](#static-html)
1616
- [React (Vite)](#react-vite)
17+
- [Vue (Vite)](#vue-vite)
1718
- [Next.js](#nextjs)
19+
- [Nuxt](#nuxt)
1820
- [Astro](#astro)
1921
- [Hugo](#hugo)
2022
- [WordPress](#wordpress)
@@ -55,6 +57,30 @@ Then use `data-anim` attributes in any component:
5557

5658
No `useEffect`, no refs, no wrapper components needed.
5759

60+
## Vue (Vite)
61+
62+
Install via npm:
63+
64+
<CodeBlock code={'npm install data-anim'} lang="bash" />
65+
66+
Import once at the top of your entry file. data-anim auto-initializes and uses MutationObserver to detect components as they mount.
67+
68+
<CodeBlock
69+
code={'// src/main.js\nimport \'data-anim\';\nimport { createApp } from \'vue\';\nimport App from \'./App.vue\';\n\ncreateApp(App).mount(\'#app\');'}
70+
lang="js"
71+
filename="src/main.js"
72+
/>
73+
74+
Then use `data-anim` attributes in any component:
75+
76+
<CodeBlock
77+
code={'<template>\n <section data-anim-stagger="100">\n <h2 data-anim="fadeInUp">Features</h2>\n <div data-anim="fadeInUp">Fast</div>\n <div data-anim="fadeInUp">Lightweight</div>\n <div data-anim="fadeInUp">Zero config</div>\n </section>\n</template>'}
78+
lang="vue"
79+
filename="src/components/Features.vue"
80+
/>
81+
82+
No `onMounted`, no refs, no directives needed.
83+
5884
## Next.js
5985

6086
Install via npm:
@@ -69,10 +95,10 @@ Import in your root layout. Use `next/script` with `strategy="beforeInteractive"
6995
filename="app/layout.tsx"
7096
/>
7197

72-
Alternatively, import the npm package via a Client Component:
98+
Alternatively, import the npm package via a Client Component. Note: data-anim accesses `document` at module level, so use a dynamic import inside `useEffect` to avoid SSR errors:
7399

74100
<CodeBlock
75-
code={'// app/DataAnim.tsx\n\'use client\';\nimport \'data-anim\';\nexport default function DataAnim() {\n return null;\n}'}
101+
code={'// app/DataAnim.tsx\n\'use client\';\nimport { useEffect } from \'react\';\n\nexport default function DataAnim() {\n useEffect(() => {\n import(\'data-anim\');\n }, []);\n return null;\n}'}
76102
lang="tsx"
77103
filename="app/DataAnim.tsx"
78104
/>
@@ -91,6 +117,30 @@ Then use attributes in any Server or Client Component:
91117
filename="app/page.tsx"
92118
/>
93119

120+
## Nuxt
121+
122+
Install via npm:
123+
124+
<CodeBlock code={'npm install data-anim'} lang="bash" />
125+
126+
Create a client-only plugin. The `.client.ts` suffix ensures data-anim only loads in the browser, avoiding SSR errors:
127+
128+
<CodeBlock
129+
code={'// app/plugins/data-anim.client.ts\nimport \'data-anim\';\nexport default defineNuxtPlugin(() => {});'}
130+
lang="ts"
131+
filename="app/plugins/data-anim.client.ts"
132+
/>
133+
134+
Then use attributes in any component or page:
135+
136+
<CodeBlock
137+
code={'<!-- app/app.vue -->\n<template>\n <div>\n <h1 data-anim="fadeInUp">Welcome</h1>\n <p data-anim="fadeInUp" data-anim-delay="200">\n Built with Nuxt + data-anim\n </p>\n </div>\n</template>'}
138+
lang="vue"
139+
filename="app/app.vue"
140+
/>
141+
142+
No extra configuration in `nuxt.config.ts` needed. Nuxt auto-imports plugins from the `app/plugins/` directory.
143+
94144
## Astro
95145

96146
Add to your base layout:

0 commit comments

Comments
 (0)