Vue 3 Admin Dashboard from Scratch: A 19-Step Guide with Real Gotchas
A reproducible 19-step setup like this saves developers days of assembling tooling and debugging mismatched versions. It also documents non-obvious failure points—forgetting to register VueQueryPlugin, pnpm 12 ignoring build scripts, or TypeScript 6 deprecating baseUrl—that typically only surface during real builds, making it a practical reference for anyone building Vue 3 admin dashboards.
Starting from an empty folder, the guide scaffolds a Vue 3 + TypeScript project with pnpm and Vite, adds ESLint flat config, Prettier, and strict TypeScript, and establishes a domain-based directory structure with a path alias configured in both Vite and TypeScript. Core features, each with a minimal example, include Element Plus menus and tables, Vue Router with lazy loading and a login guard, Pinia stores for user and UI state (with persistence for theme and locale), an Axios wrapper with interceptors for auth tokens and idempotency keys, and TanStack Query for server state with caching and invalidation.
The guide then covers internationalization with vue-i18n, a v-permission directive for button-level access control, ECharts via a reusable wrapper component, Day.js helpers with timezone discipline, CSS-variable theming that syncs with Element Plus dark mode, mock data fallbacks (with a warning against shipping mock code), and Vitest unit tests focused on pure utilities. It finishes with git hooks via simple-git-hooks and lint-staged for pre-commit checks, a command cheat sheet, and a detailed list of nine real-world gotchas, including pnpm 12 blocking install scripts, forgetting to register VueQueryPlugin, and ESLint getting polluted by Chrome profile files. The guide deliberately keeps each step minimal and defers production-grade patterns to a separate theoretical notebook.
The guide's deliberate separation of a minimal working example from a 'theoretical notebook' for production patterns reflects a practical learning approach that prevents beginners from drowning in advanced configurations while still pointing to them.
The gotchas list shows that modern toolchains have moving parts that trip up even seasoned developers; documenting such failures is often more valuable than the happy-path instructions.
The decision to test only pure utilities and skip component tests for business pages challenges the notion that all code needs unit tests, arguing that the maintenance cost of mocking routes, stores, and APIs often outweighs the benefit.
The emphasis on not persisting tokens and using HTTP-only refresh tokens for production highlights how even a beginner demo respects security boundaries.