Next Generation file based typed routing for Vue Router
unplugin-vue-router is a build-time plugin designed to simplify routing setup in Vue applications with TypeScript support. It enhances the safety and ease of use of Vue Router >=4.4.0 by providing automatic file-based routing.
To install unplugin-vue-router, follow these steps:
// Example:
playground/Setup
npm run dev
) to generate the initial types version.tsconfig.json
.env.d.ts
file, add the unplugin-vue-router/client
types to it. If you don’t have an env.d.ts
file, you can create one and add the types or add them to the types
property in your tsconfig.json
.vue-router/auto-routes
and pass them to the router. You can also import the routes array and manually create the router or pass it to a plugin.unplugin-vue-router is a valuable tool for Vue developers looking to simplify and enhance their routing setup, particularly when working with TypeScript. By automating file-based routing and providing TypeScript support, this plugin reduces setup complexity and enhances code safety. Developers can leverage its features to streamline routing configuration in Vue applications.