Vue Example
A Vue example with composables, plugin setup, and object-aware checks
Purpose
examples/vue shows the official Vue adapter in its simplest realistic form. A user is loaded, the Permix instance is set up from that user, and components reactively check whether the current post can be edited.
What it demonstrates
- the
permixPluginfor app-wide access - a custom
usePermissions()composable - watching the user and refreshing permissions when it changes
- slot-based fallback rendering with the Vue
Checkcomponent
Core idea
The example sets up one readable permission and one data-aware predicate:
return permix.setup({
post: {
read: true,
edit: post => post?.authorId === user.id,
},
})Inside the template, the Check component exposes an otherwise slot for denied UI:
<Check entity="post" :action="['edit', 'read']" :data="post">
I can edit a post inside the Check component
<template #otherwise>
I don't have permission to edit a post inside the Check component
</template>
</Check>Run it
cd examples/vue
pnpm devKey files
src/lib/permix.ts: Vue Permix instance and generatedCheckcomponentsrc/composables/permissions.ts: composable wrapper aroundusePermixsrc/App.vue: watch-based setup and post-level checks
When to use it
Use this example if you want a Vue-first integration reference without SSR or router complexity.