From: Alexander Lichter Date: Fri, 21 Feb 2025 16:42:59 +0000 (+0100) Subject: docs: update nuxt docs to recommend callOnce (#2916) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fv2;p=thirdparty%2Fvuejs%2Fpinia.git docs: update nuxt docs to recommend callOnce (#2916) --- diff --git a/packages/docs/ssr/nuxt.md b/packages/docs/ssr/nuxt.md index 592ab0fc..f003a240 100644 --- a/packages/docs/ssr/nuxt.md +++ b/packages/docs/ssr/nuxt.md @@ -43,22 +43,23 @@ And that's it, use your store as usual! ## Awaiting for actions in pages -As with `onServerPrefetch()`, you can call a store action within `asyncData()`. Given how `useAsyncData()` works, **make sure to return a value**. This will allow Nuxt to skip running the action on the client side and reuse the value from the server. +As with `onServerPrefetch()`, you can call a store action within the `callOnce()` composable. +This will allow Nuxt to run the action only once and avoids refetching data that is already present. ```vue{3-4} ``` -If your action doesn't resolve a value, you can add any non nullish value: +Depending on your requirements, you can choose to run the action only once on the client, or on every navigation (which is closer to data fetching behavior of `useFetch()`/`useAsyncData()`) ```vue{3} ```