vite-plugin-pages is a Vite plugin that enables file system-based routing for modern JavaScript frameworks, currently supporting Vue 3, React, and SolidJS applications. As of version 0.33.3, the project maintains an active development pace, regularly updating to support the latest Vite versions (e.g., v8, v7, v6, v5 were recently added). Its core value proposition is simplifying route management by automatically generating routes from a predefined directory structure, eliminating the need for manual route configuration in large applications. However, a significant recommendation is that for Vue users, the official `unplugin-vue-router` is generally preferred due to its deeper integration with `vue-router`'s internals and advanced features like auto-generated route types with autocomplete, offering a more tailored developer experience. This positions `vite-plugin-pages` as a robust, general-purpose solution particularly valuable for React and SolidJS ecosystems, or for simpler Vue setups where advanced `vue-router` integration might not be a primary concern.
npm install vite-plugin-pagesVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure `vite-plugin-pages` in `vite.config.ts` and integrate the auto-generated routes into a basic Vue 3 application, including common options.
Consider migrating to `unplugin-vue-router` for new Vue projects or for existing projects seeking enhanced Vue Router integration and type safety.
Review your `vite.config.ts` and remove any deprecated options. Refer to the latest documentation for `vite-plugin-pages` to use currently supported configuration properties.
Ensure your Vite configuration and project are set up for ESM. Update import statements from `const Pages = require('vite-plugin-pages')` to `import Pages from 'vite-plugin-pages'`.Upgrade `react-router` to v6 or higher, or explicitly install `vite-plugin-pages@0.18.2` if `react-router@5` must be retained.
Change `const Pages = require('vite-plugin-pages')` to `import Pages from 'vite-plugin-pages'` in your `vite.config.ts` and ensure your project is configured for ESM.Use the correct default import syntax: `import routes from '~pages'` (for Vue), `import routes from '~react-pages'` (for React), or `import routes from '~solid-pages'` (for Solid).
Remove the unrecognized option from your `vite.config.ts`. Consult the official `vite-plugin-pages` documentation for the latest configuration options.