From 9a8700a010e546688cfd4733d1bc587e0f1ec374 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Fri, 21 Feb 2025 17:42:59 +0100 Subject: [PATCH] docs: update nuxt docs to recommend callOnce (#2916) --- packages/docs/ssr/nuxt.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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} ``` -- 2.39.5