Nuxt demo update

- Updates the demo for Nuxt, no need to import the composable and use the client suffix in the file name
- Updates the README.MD file in the examples folder
- Updates the SKILL.md file in the frameworks folder
This commit is contained in:
Rodrigo Hernando
2026-04-10 14:18:08 -04:00
parent 63353bf7a2
commit 7f8b61e6e9
4 changed files with 5 additions and 9 deletions
+2 -2
View File
@@ -24,6 +24,6 @@ These examples are intended as reference implementations for AI agents and for q
## Nuxt
- **examples/nuxt/** — Nuxt 4 with GSAP client-only re-usable composable.
- **examples/nuxt/** — Nuxt 4 with GSAP re-usable composable.
- From repo root: `cd examples/nuxt && npm install && npm run dev`.
- Patterns: GSAP as client-only composable (`useGSAP.client.ts`), for gsap access, lazy-loading plugins, `gsap.context(() => {}, scope)` cleanup.
- Patterns: GSAP as reusable composable (`useGSAP.ts`), for gsap access, lazy-loading plugins, `gsap.context(() => {}, scope)` cleanup.
-1
View File
@@ -1,6 +1,5 @@
<script setup>
import { onMounted, onUnmounted } from "vue";
import useGSAP from "./composables/useGSAP.client";
const { gsap, ScrollTrigger, lazyLoadPlugin } = useGSAP();
+3 -6
View File
@@ -89,14 +89,14 @@ onUnmounted(() => {
</template>
```
## Nuxt 3
## Nuxt 4
> See `examples/nuxt/` for a runnable Nuxt 4 project with plugin registration, lazy loading, and SSR-safe patterns.
Use a **client-only composable** (`.client.ts` suffix) to register GSAP Plugins, it never runs on the server:
Use a **reusable composable** to register GSAP Plugins and also to lazy load Plugins that are not extensively used in your application:
```typescript
// composables/useGSAP.client.ts
// composables/useGSAP.ts
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
@@ -193,12 +193,9 @@ export default function () {
Access in components via `useGSAP()`:
```javascript
import useGSAP from "./composables/useGSAP.client";
const { gsap, ScrollTrigger, lazyLoadPlugin } = useGSAP();
```
- ✅ **`.client.ts` suffix** ensures the composable only runs in the browser (SSR-safe). Never import GSAP in server-rendered code.
- ✅ **`useGSAP()`** provides typed access to the gsap instance and lazy load method.
- ✅ **Lazy-load any plugin** (SplitText, MorphSVG, etc.) that is not widely used in your app to reduce initial bundle size.
- ✅ Use **gsap.context(scope)** and **onUnmounted → ctx.revert()** in components, same as Vue 3.