callOnce issues
im attempting to use callOnce to fetch session information for the current user visiting my site with option:
mode: "navigation"
. i looked at nuxt source and it hooks page:start
, which ive realized only happens when the page is "loaded/reloaded" you could say. it becomes especially noticeable when i figured out that that hook is only called when the app is rendered for the first time, or when nuxt returns from a recoverable error (which was not client side navigation). what can i do to make it behave normally (where client side navigation counts)?2 Replies
Hi @hankxefey. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the available knowledge sources, the intended behavior of callOnce with { mode: 'navigation' } is to execute the provided function once during the initial render and then on every client-side navigation. This feature was introduced in Nuxt v3.15 and is documented as follows:
- Ensure you are using at least Nuxt v3.15, as navigation mode is only available from this version. - Double-check your usage matches the documented pattern. - If the issue persists, consider reporting it as a bug to the Nuxt team, as the documented behavior should cover client-side navigations as you expect. I'm sorry, but the knowledge sources do not contain more detailed troubleshooting steps or alternative solutions for this specific issue with callOnce and navigation mode. For now, following the official documentation and ensuring your Nuxt version is up to date is the best course of action.
Docs > callOnce ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
It is also possible to run on every navigation while still avoiding the initial server/client double load. For this, it is possible to use the navigation mode:>
>
The documentation does not mention any limitation where callOnce in navigation mode would only trigger on initial load or after a recoverable error. It explicitly states that it should run "on every client side navigation." If you are observing that callOnce is not running on every client-side navigation, this may indicate a bug or an unexpected behavior in your specific Nuxt version or setup. The knowledge sources do not provide a workaround or deeper technical details about the internal hook implementation or known issues with the navigation mode. Recommendation:navigation
mode is available since Nuxt v3.15.
Docs > callOnce
- Ensure you are using at least Nuxt v3.15, as navigation mode is only available from this version. - Double-check your usage matches the documented pattern. - If the issue persists, consider reporting it as a bug to the Nuxt team, as the documented behavior should cover client-side navigations as you expect. I'm sorry, but the knowledge sources do not contain more detailed troubleshooting steps or alternative solutions for this specific issue with callOnce and navigation mode. For now, following the official documentation and ensuring your Nuxt version is up to date is the best course of action.
Docs > callOnce ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@1224044578366292018> Kapa.ai is still learning and improving, please let me know how I did by reacting below.