You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/2.setup.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
2
title: Setup
3
-
description: Learn how to setup strapi module in your Nuxt 3 application.
3
+
description: Learn how to setup the Strapi module in your Nuxt application.
4
4
navigation.icon: i-lucide-play
5
5
---
6
6
7
7
## Installation
8
8
9
-
1.Add `@nuxtjs/strapi` module to your project:
9
+
Add `@nuxtjs/strapi` module to your project:
10
10
11
11
```bash
12
12
npx nuxi@latest module add strapi
13
13
```
14
14
15
-
2. Add it to the `modules` section in your `nuxt.config.ts`:
15
+
This will add the module to the `modules` section of your `nuxt.config.ts`. You can then configure it:
16
16
17
17
```ts [nuxt.config.ts]
18
18
exportdefaultdefineNuxtConfig({
@@ -39,7 +39,7 @@ Defaults:
39
39
}
40
40
```
41
41
42
-
If you want to override any options on runtime, you may use [Nuxt 3 runtime-config](https://nuxt.com/docs/getting-started/configuration#environment-variables-and-private-tokens):
42
+
If you want to override any options on runtime, you may use [Nuxt runtime-config](https://nuxt.com/docs/getting-started/configuration#environment-variables-and-private-tokens):
Depending on which version you have in your [options](/setup#options), you will be using either the v5 (default), v4 or v3 client.
12
12
13
-
::prose-tip
13
+
::tip
14
14
All examples below are demonstrated with the default v5 `useStrapi()`. :br
15
15
:br
16
-
Note that v3/v4 expose similar methods with different options. Check out specific types for [v5](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v5.ts), [v4](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v4.ts) or [v3](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v3.ts).
16
+
Note that v3/v4 expose similar methods with different options. Check out specific types for [v5](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/types/v5.ts), [v4](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/types/v4.ts) or [v3](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/types/v3.ts).
17
17
::
18
18
19
19
> Learn how to handle Strapi errors globally by using [nuxt hooks](/advanced#errors-handling).
20
20
21
-
::prose-warning
21
+
::warning
22
22
All examples below are demonstrated with http calls in script setup. However, to handle SSR properly you may want to use [useAsyncData](/advanced#async-data).
23
23
::
24
24
25
-
### Types
26
-
27
25
When using the composable, you can pass in a default data model for all methods.
28
26
29
27
```ts
@@ -48,7 +46,7 @@ Get a list of documents. Returns entries matching the query filters (see [parame
Pass `locale` to delete a specific locale version: `_delete('restaurants', id, { locale: 'fr' })`
164
162
::
165
163
@@ -169,13 +167,13 @@ Pass `locale` to delete a specific locale version: `_delete('restaurants', id, {
169
167
170
168
Returns the count of entries matching the query filters. You can read more about parameters [here](https://docs-v3.strapi.io/developer-docs/latest/developer-resources/content-api/content-api.html#api-parameters).
171
169
172
-
::prose-warning
170
+
::warning
173
171
Available only for `v3` as Strapi v4 can do the same thing with the [Pagination queries](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#pagination) of the `find` method.
This composable is a wrapper around [Nuxt 3 `$fetch` helper](https://nuxt.com/docs/api/utils/dollarfetch) that uses [`ofetch`](https://github.com/unjs/ofetch) under the hood. You can use this method to reach custom strapi endpoints not available in the `useStrapi` composable.
220
+
This composable is a wrapper around [Nuxt `$fetch` helper](https://nuxt.com/docs/api/utils/dollarfetch) that uses [`ofetch`](https://github.com/unjs/ofetch) under the hood. You can use this method to reach custom strapi endpoints not available in the `useStrapi` composable.
Copy file name to clipboardExpand all lines: docs/content/4.auth.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
2
2
title: Authentication
3
-
description: Learn how to authenticate users with the strapi module in your Nuxt 3 application.
3
+
description: Learn how to authenticate users with the Strapi module in your Nuxt application.
4
4
navigation.icon: i-lucide-lock
5
5
---
6
6
7
-
> This module exposes composables that are [auto-imported](https://nuxt.com/docs/guide/directory-structure/composables) by Nuxt 3.
7
+
> This module exposes composables that are [auto-imported](https://nuxt.com/docs/guide/directory-structure/composables) by Nuxt.
8
8
9
9
## Configuration
10
10
11
11
When using `@nuxtjs/strapi` for authentication, the user jwt token will be stored in a cookie (`strapi_jwt` by default). By using the default cookie configuration, the expiration will be set to `Session`, which means the cookie will disappear when the browser is closed, and users will have to log in everytime.
12
12
13
-
If you want your cookie to stay longer, we recommand to use the configuration below (expiration is set to 14 days, feel free to change it):
13
+
If you want your cookie to stay longer, we recommend using the configuration below (expiration is set to 14 days, feel free to change it):
14
14
15
15
```ts [nuxt.config.ts]
16
16
exportdefaultdefineNuxtConfig({
@@ -47,7 +47,7 @@ const token = useStrapiToken()
47
47
48
48
This composable exposes all the methods available in the Strapi [Users & Permissions plugin](https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html).
49
49
50
-
::prose-tip
50
+
::tip
51
51
On `login`, `register`, `resetPassword` and `authenticateProvider` methods, the user is populated through the [`fetchUser`](/auth#fetchuser) method.
52
52
::
53
53
@@ -56,8 +56,8 @@ On `login`, `register`, `resetPassword` and `authenticateProvider` methods, the
56
56
Submit the user's identifier and password credentials for authentication. Sets [`user`](/auth#usestrapiuser) and [`token`](/auth#usestrapitoken).
This action sends an email to a user with the link to your own reset password page. The link will be enriched with the url param code that is needed for the [`resetPassword`](/auth#resetpassword).
Fetch `me` user from `/users/me` route if a [`token`](/auth#usestrapitoken) exists in the cookies then sets [`user`](/auth#usestrapiuser).
260
260
261
-
::prose-tip
261
+
::tip
262
262
This method is called on the server-side only and the data are hydrated client-side so the HTTP call happens only once. This method is called by default on init through a [Nuxt plugin](https://nuxt.com/docs/guide/directory-structure/plugins), so you don't have to.
> Check out the [Strapi5Error](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v5.ts#L3) or [Strapi4Error](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v4.ts#L3) type.
92
+
> Check out the [Strapi5Error](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/types/v5.ts#L3) or [Strapi4Error](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/types/v4.ts#L3) type.
> Check out the [Strapi3Error](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v3.d.ts#L3) type.
115
+
> Check out the [Strapi3Error](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/types/v3.ts#L3) type.
116
116
117
117
## Override Strapi `/users/me` route
118
118
119
-
::prose-tip
119
+
::tip
120
120
Since [v1.5.0](https://github.com/nuxt-modules/strapi/releases/tag/v1.5.0) and Strapi [v4.2.2](https://github.com/strapi/strapi/releases/tag/v4.2.2), you can use the [`auth.populate`](/setup#authpopulate) option to populate data from `/users/me` route.
121
121
::
122
122
@@ -138,7 +138,7 @@ module.exports = {
138
138
}
139
139
```
140
140
141
-
> Note that in Strapi v4v5, you must enable the `restaurants.find` permission in your admin for the Authenticated role to have the data populated.
141
+
> Note that in Strapi v4/v5, you must enable the `restaurants.find` permission in your admin for the Authenticated role to have the data populated.
142
142
143
143
### `v3`
144
144
@@ -180,7 +180,7 @@ async function onSubmit () {
180
180
</script>
181
181
```
182
182
183
-
> Note that you have to use the `client` because `create` and `update` methods sends the [body inside `data`](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/composables/useStrapi4.ts#L64).
183
+
> Note that you have to use the `client` because `create` and `update` methods sends the [body inside `data`](https://github.com/nuxt-modules/strapi/blob/main/src/runtime/composables/useStrapi4.ts#L64).
0 commit comments