@totorobin/vue-auth-directive
TypeScript icon, indicating that this package has built-in type declarations

0.1.14 • Public • Published

VueAuthDirective

This is a vue plugin allowing you to use two directives 'v-auth' and 'v-auth-else' to show component if a habilitation allow it

Example

define the plugin with acess rights levels

const role = ref('admin')
createApp(App).use(authPlugin, {
    accessRights: {
        admin: computed(() => role.value === 'admin'),
    }
}).mount('#app')

then anywhere in your application you can use v-auth directives:

<div v-auth.admin>
   components you can only use if you are an admin
</div>
<div v-auth-else>
   this will not show if you are an admin but will otherwise
</div>

Readme

Keywords

Package Sidebar

Install

npm i @totorobin/vue-auth-directive

Weekly Downloads

1

Version

0.1.14

License

ISC

Unpacked Size

6.27 kB

Total Files

6

Last publish

Collaborators

  • totorobin