nuxt-tanstack-mastery

mOdrA40's avatarfrom mOdrA40

Panduan senior/lead developer 20 tahun pengalaman untuk Vue.js 3 + Nuxt 3 + TanStack Query development. Gunakan skill ini ketika: (1) Membuat project Nuxt 3 baru dengan arsitektur production-ready, (2) Integrasi TanStack Query untuk data fetching, (3) Debugging Vue/Nuxt yang kompleks, (4) Review code untuk clean code compliance, (5) Optimisasi performa aplikasi Vue/Nuxt, (6) Setup folder structure yang scalable, (7) Mencari library terpercaya untuk Vue ecosystem, (8) Menghindari common pitfalls dan bugs, (9) Implementasi state management patterns, (10) Security hardening aplikasi Nuxt.Trigger keywords: vue, vuejs, nuxt, nuxtjs, tanstack, vue-query, composition api, pinia, vueuse, vue router, clean code vue, debugging vue, folder structure nuxt.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 27, 2025

When & Why to Use This Skill

This Claude skill acts as a senior lead developer guide for building production-ready Vue.js 3 and Nuxt 3 applications. It specializes in TanStack Query integration, scalable architecture, and performance optimization, ensuring high-quality code through proven design patterns, TypeScript strictness, and security best practices.

Use Cases

  • Architecting a new Nuxt 3 project from scratch using a scalable, feature-based folder structure designed for long-term maintenance.
  • Implementing advanced data fetching, caching, and optimistic updates using TanStack Query to enhance application responsiveness.
  • Refactoring legacy Vue code into modern Composition API patterns while ensuring clean code compliance and reactivity best practices.
  • Optimizing web performance through bundle analysis, lazy loading strategies, and efficient state management with Pinia.
  • Hardening application security by implementing Content Security Policy (CSP), Zod-based input validation, and secure authentication workflows.
  • Debugging complex reactivity issues and performance bottlenecks in large-scale Vue/Nuxt environments.
namenuxt-tanstack-mastery
description|
Gunakan skill ini ketika(1) Membuat project Nuxt 3 baru dengan arsitektur production-ready, (2) Integrasi TanStack Query untuk data fetching, (3) Debugging Vue/Nuxt yang kompleks, (4) Review code untuk clean code compliance, (5) Optimisasi performa aplikasi Vue/Nuxt, (6) Setup folder structure yang scalable, (7) Mencari library terpercaya untuk Vue ecosystem, (8) Menghindari common pitfalls dan bugs, (9) Implementasi state management patterns, (10) Security hardening aplikasi Nuxt.
Trigger keywordsvue, vuejs, nuxt, nuxtjs, tanstack, vue-query, composition api, pinia, vueuse, vue router, clean code vue, debugging vue, folder structure nuxt.

Nuxt 3 + TanStack Query Mastery

Filosofi: "Simplicity is the ultimate sophistication" — Write code that your future self will thank you for.

Core Principles (WAJIB dipatuhi)

┌─────────────────────────────────────────────────────────────────┐
│  1. KISS (Keep It Stupid Simple) - Jangan over-engineer        │
│  2. YAGNI (You Ain't Gonna Need It) - Build for today          │
│  3. DRY (Don't Repeat Yourself) - Tapi jangan premature DRY    │
│  4. Composition over Inheritance - Favor composables           │
│  5. Single Responsibility - One function, one job              │
│  6. Explicit over Implicit - Readable > clever                 │
└─────────────────────────────────────────────────────────────────┘

Quick Decision Matrix

Kebutuhan Solusi Referensi
Data fetching + caching TanStack Query tanstack-query.md
Global state sederhana Pinia state-management.md
Utility functions VueUse libraries.md
Form handling VeeValidate + Zod libraries.md
Debugging Vue DevTools + patterns debugging.md
Folder structure Feature-based folder-structure.md
Performance issues Profiling + lazy load performance.md
Security concerns CSP + validation security.md
Common bugs Reactivity gotchas common-pitfalls.md

Reference Files

Baca reference yang relevan berdasarkan kebutuhan:

Golden Rules (Cetak dalam otak)

1. Composables adalah Raja

// ❌ JANGAN: Logic di component
const MyComponent = {
  setup() {
    const data = ref([])
    const loading = ref(false)
    const fetchData = async () => { /* ... */ }
    // 50 lines of logic...
  }
}

// ✅ LAKUKAN: Extract ke composable
// composables/useProducts.ts
export function useProducts() {
  const { data, isLoading } = useQuery({ /* ... */ })
  return { products: data, isLoading }
}

// Component menjadi bersih
const { products, isLoading } = useProducts()

2. TypeScript adalah Non-negotiable

// ❌ any = technical debt
const data: any = await fetch()

// ✅ Type everything
interface Product {
  id: string
  name: string
  price: number
}
const data: Product[] = await fetch()

3. Error Boundaries WAJIB ada

<!-- Wrap setiap section dengan error boundary -->
<NuxtErrorBoundary>
  <ProductList />
  <template #error="{ error }">
    <ErrorDisplay :error="error" />
  </template>
</NuxtErrorBoundary>

4. Reactivity dengan Benar

// ❌ Reactivity loss
const { data } = useQuery()
const items = data.value // Loss reactivity!

// ✅ Preserve reactivity
const { data } = useQuery()
const items = computed(() => data.value ?? [])

Project Bootstrap Command

# Nuxt 3 + TanStack Query + Essential tools
npx nuxi@latest init my-app
cd my-app
npm install @tanstack/vue-query @pinia/nuxt @vueuse/nuxt zod @vee-validate/nuxt
npm install -D @nuxt/devtools typescript @types/node

Checklist Sebelum Production

  • TypeScript strict mode enabled
  • Error boundaries di setiap route
  • Loading states untuk semua async operations
  • Input validation dengan Zod
  • Environment variables di .env (bukan hardcode)
  • Bundle size < 200KB initial JS
  • Lighthouse score > 90
  • Security headers configured
  • Rate limiting untuk API calls
  • Proper caching strategy dengan TanStack Query