Skip to content

Commit ffc1c4e

Browse files
committed
docs: explain usage with v4 and fix component props
fix #14 fix #13
1 parent 31f1dd4 commit ffc1c4e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ Easy!
137137

138138
### Define Abilities
139139

140+
> [!NOTE]
141+
> With the upcoming Nuxt4, you can store your abilities in the `app/utils/abilities.ts` file. Then, you can import them in your server folder using `~/utils/abilities`.
142+
> See an example with [the project Orion](https://github.com/Barbapapazes/orion/blob/main/app/utils/users/abilities.ts).
143+
144+
> [!NOTE]
145+
> With Nuxt4, a new `shared` directory will be introduced to easily share code between the client and the server.
146+
> See [the issue](https://github.com/nuxt/nuxt/issues/28675).
147+
140148
Now the resolvers are set up, you can define your first ability. An ability is a function that takes at least the user, and returns a boolean to indicate if the user can perform the action. It can also take additional arguments.
141149

142150
I recommend to create a new file `utils/abilities.ts` to create your abilities:
@@ -212,8 +220,8 @@ The module provides 2 components help you to conditionally show part of the UI.
212220
```vue
213221
<template>
214222
<Can
215-
:ability="editPost"
216-
:args="[post]"
223+
:bouncer-ability="editPost"
224+
:args="[post]" // Optional if the ability does not take any arguments
217225
>
218226
<button>Edit</button>
219227
</Can>
@@ -227,8 +235,8 @@ As a counterpart, you can use the `Cannot` component to render the button only i
227235
```vue
228236
<template>
229237
<Cannot
230-
:ability="editPost"
231-
:args="[post]"
238+
:bouncer-ability="editPost"
239+
:args="[post]" // Optional if the ability does not take any arguments
232240
>
233241
<p>You're not allowed to edit the post.</p>
234242
</Cannot>

0 commit comments

Comments
 (0)