@programic/vue-router-middleware
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@programic/vue-route-middleware

Make complex global route middleware logic look easy and readable!

Installation:

npm i @programic/vue-route-middleware

yarn add @programic/vue-route-middleware

Basic Usage:

Set middleware meta key to your route and add our component to any vue router guard hook.

import { withPipeline } from '@programic/vue-route-middleware';
import middlewares from '..';

...
const router = withPipeline(createRouter({
  ...
}), middlewares);

createApp(App).use(router);

NOTICE: Middleware function will retrieve all the variables normally passed to the router guards
Example: (to, from, next) in case of beforeEach or (to, from) in case of afterEach guard.

router.js

import AuthMiddleware from './route/middleware/auth';
...
meta: {
    middleware: [ AuthMiddleware ]
}
...

Credits:

Package Sidebar

Install

npm i @programic/vue-router-middleware

Weekly Downloads

0

Version

1.2.0

License

ISC

Unpacked Size

8.92 kB

Total Files

4

Last publish

Collaborators

  • rbongers
  • thimonwentink
  • remcowolvenne