Vite plugin providing a meta-based layout system for vue-router. Current version 0.6.1 (released 2023), with active development and frequent releases. Key differentiator from vite-plugin-vue-layouts: proper HMR support in modern Vite versions. Allows defining layouts via route meta (e.g., meta: { layout: 'other' }) or using a default layout. Supports both sync and async import modes, file-based routing plugins (vite-plugin-pages, unplugin-vue-router), customizable layout directory, excludes, and meta field name. Written in TypeScript with bundled types. Requires Vite >=2.0.0 and vue-router >=4.0.14.
npm install vite-plugin-vue-meta-layoutsVerified import paths — ran on the pinned version, not inferred.
Shows installation, plugin registration, creating a default layout, and using setupLayouts with file-based route objects including meta layout override.
Use `import { setupLayouts } from 'virtual:meta-layouts'` in your route configuration file.If you were relying on the meta field name before v0.6.0, it remains 'layout' by default. Only breaking if you used a different metaName explicitly.
Only set skipTopLevelRouteLayout: true if you encounter the nested route issue referenced in https://github.com/JohnCampionJr/vite-plugin-vue-layouts/issues/134.
Use glob patterns like 'excludes: ['**/secret/*']' to exclude routes from layout wrapping.
Add `"types": ["vite-plugin-vue-meta-layouts/client"]` to your tsconfig.json compilerOptions.
Ensure src/layouts/default.vue exists and exports a valid Vue component. Or change defaultLayout option to an existing layout.
Change import to `import { setupLayouts } from 'virtual:meta-layouts'`.