Vite plugin that statically extracts metadata from React component files and generates client-side route declarations, currently at version 0.4.2 (pre-release, API unstable). Instead of file-system-based routing, this plugin allows developers to define routes inline within component files using a Meta export, providing flexibility in code organization. It generates a virtual module 'virtual:pagefiles' containing route configurations. Currently supports React only, but extensible to other frameworks. Releases are on GitHub but no fixed cadence. Key differentiator: route metadata lives inside the component file, not the file path, decoupling URL structure from file organization.
npm install vite-plugin-pagefilesVerified import paths — ran on the pinned version, not inferred.
Creates a React SPA with pagefiles: configure Vite plugin, define a page component with Meta export, consume generated routes with React Router.
Pin to exact version and expect manual migration with each update.
Use other frameworks (e.g., Next.js) if React is not your choice, or consider contributing support.
Only import 'virtual:pagefiles' within files processed by Vite (e.g., inside src/).
Add <Suspense fallback={...}> around the component using useRoutes(routes).Add a declaration file (e.g., src/pagefiles.d.ts) with: declare module 'virtual:pagefiles' { import { RouteObject } from 'react-router-dom'; const routes: RouteObject[]; export default routes; }Change import { pagefiles } from 'vite-plugin-pagefiles' to import pagefiles from 'vite-plugin-pagefiles'.Wrap the component that calls useRoutes(routes) in <Suspense fallback={<div>Loading...</div>}>.