kozy
Store usage/relevance with Nuxt 3
When working on my various Vue 2 projects (around 5 SPA web applications) I found Vuex incredibly useful. Namely, it provided a single place for my logic around interfacing with my .NET API, as well helping share state between components.
However, as I've started writing more in Vue 3, especially given nuxt composables/plugins like $fetch, useFetch, useAsyncData, callOnce, useState, etc. I've found myself struggling to justify this default of 'relates to api data, put it in the store'.
For instance, I'll have a card that needs some async data. If I load it in the card, I have access to the returns/capabilities of useFetch like
watch
, error
, loading
, etc. If i wanted that call in the store, i would need to expose each of these. Furthermore, my stores become a bunch of inline composables related to components.
I'm curious if anyone else has had a similar experience/any thoughts. Happy to go into more detail5 replies