
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
unplugin-vue-router
Advanced tools
unplugin-vue-router is a plugin for Vue.js that provides enhanced routing capabilities. It simplifies the process of defining and managing routes in a Vue.js application, offering features like automatic route generation, route guards, and more.
Automatic Route Generation
This feature allows you to automatically generate routes based on the file structure of your project. It simplifies the process of setting up routes by eliminating the need to manually define each route.
```javascript
import { createRouter, createWebHistory } from 'vue-router';
import routes from 'virtual:generated-pages';
const router = createRouter({
history: createWebHistory(),
routes,
});
export default router;
```
Route Guards
Route guards are used to protect certain routes based on conditions such as authentication status. This feature allows you to define global or per-route guards to control access to different parts of your application.
```javascript
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth && !isAuthenticated()) {
next({ name: 'login' });
} else {
next();
}
});
```
Dynamic Routing
Dynamic routing allows you to define routes with dynamic segments, such as user IDs. This feature is useful for creating routes that depend on variable parameters.
```javascript
const routes = [
{ path: '/user/:id', component: UserComponent }
];
const router = createRouter({
history: createWebHistory(),
routes,
});
```
vue-router is the official router for Vue.js. It provides a comprehensive set of features for routing in Vue.js applications, including nested routes, route guards, and dynamic routing. Compared to unplugin-vue-router, vue-router requires more manual setup for route definitions but offers a high level of customization.
vite-plugin-pages is a Vite plugin that automatically generates routes based on the file structure of your project. It is similar to unplugin-vue-router in that it simplifies route management, but it is specifically designed to work with Vite, a build tool that is often used with Vue.js.
Zero-config File based type safe Routing
This build-time plugin simplifies your routing setup and makes it safer and easier to use thanks to TypeScript.
ā ļø This package is still experimental. If you found any issue, design flaw, or have ideas to improve it, please, open an issue or a Discussion.
npm i unplugin-vue-router
// vite.config.ts
import VueRouter from 'unplugin-vue-router/vite'
export default defineConfig({
plugins: [
VueRouter({
/* options */
}),
],
})
Example: playground/
// rollup.config.js
import VueRouter from 'unplugin-vue-router/rollup'
export default {
plugins: [
VueRouter({
/* options */
}),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-router/webpack')({
/* options */
}),
],
}
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-vue-router/webpack')({
/* options */
}),
],
},
}
Then you can replace your imports from vue-router
to @vue-router
:
-import { createRouter, createWebHistory } from 'vue-router'
+import { createRouter, createWebHistory } from '@vue-router'
createRouter({
history: createWebHistory(),
// You don't need to pass the routes anymore,
// the plugin writes it for you š¤
})
Make sure to also check the TypeScript section below if you are using TypeScript.
Have a glimpse of all the existing configuration options with their corresponding default values:
VueRouter({
// Folder(s) to scan for vue components and generate routes. Can be a string or an array of strings.
routesFolder: 'src/routes'
// Path for the generated types. Defaults to `./typed-router.d.ts` if typescript
// is installed. Can be disabled by passing `false`.
dts: './typed-router.d.ts',
})
This plugin generates a d.ts
file with all the typing overrides. Make sure to include it in your tsconfig.json
's include
or files
property:
{
// ...
"include": [/* ... */ "typed-router.d.ts"]
// ...
}
Make sure to import from @vue-router
to get access to the typed APIs instead of vue-router
. You can commit the typed-router.d.ts
file to your repository to make your life easier.
This project idea came from trying to type the router directly using Typescript, finding out it's not fast enough to be pleasant to use and, ending up using build-based tools, taking some inspiration from other projects like:
FAQs
File based typed routing for Vue Router
The npm package unplugin-vue-router receives a total of 608,940 weekly downloads. As such, unplugin-vue-router popularity was classified as popular.
We found that unplugin-vue-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.