A Vite plugin for automatic file-based routing in Vue 3, similar to Nuxt, Next.js, and UmiJS. Current stable version is 2.1.0. It generates vue-router route configurations from a directory structure, producing lazy-loaded components and nested routes automatically. Released as a dev dependency, it supports both ESM and CJS but recommends ESM. Key differentiator: lightweight, no full framework overhead, integrates directly with Vite and Vue Router without additional runtime dependencies. Does not support hot module reloading for new routes, requires page refresh after adding files. Ships TypeScript types.
npm install vite-plugin-auto-routeVerified import paths — ran on the pinned version, not inferred.
Basic setup: registers the plugin in vite.config.ts, generating routes from views folder to a file automatically.
Manually refresh the browser after adding new files.
Use ES module import: import VitePluginAutoRoute from 'vite-plugin-auto-route'
Follow the provided setup with import.meta.glob to map string paths to actual components.
Install the correct package: 'vite-plugin-auto-route'
Run npm install --save-dev vite-plugin-auto-route and ensure package.json contains it.
Use ES module import: import VitePluginAutoRoute from 'vite-plugin-auto-route'
Set routesFile to a valid file path string, e.g., './src/router/autoRoutes.ts'
Ensure pagesDir exists and contains .vue files; check the path relative to project root.