N
Nuxt4mo ago
Bazze

Pinia and useState

Im building a new store, and remembered the newish useState composable. Normally i would use ref in a Pinia store, but since useState is described in the docs as useState is an SSR-friendly ref replacement. Should i then use useState within the Pinia store? Havent been able to find anyone else asking this question. Im specifically using setup stores.
3 Replies
pyplacca
pyplacca4mo ago
Stack Overflow
Nuxt 3 - Pinia Vs useState()
Store (Pinia) Vs UseState If I am not mistaken, useState can replace any store like Pinia? Given that useState makes ref sharable across all components I have a hard time knowing if I should use a ...
Bazze
Bazze4mo ago
The question is if is should use The vue vanilla way with ref inside the pinia store
export default defineStore("currentUserStore", () => {
const user = ref(null);

return {
user,
};
});
export default defineStore("currentUserStore", () => {
const user = ref(null);

return {
user,
};
});
Or if i should use useState
export default defineStore("currentUserStore", () => {
const user = useState(null);

return {
user,
};
});
export default defineStore("currentUserStore", () => {
const user = useState(null);

return {
user,
};
});
The guy in that question asks if they should either use Pinia or useState
pyplacca
pyplacca4mo ago
There’s no point in using a global state manager insider another global state manager Can you give an example? I don’t think you got my point Exactly The second example to be precise Yeah. Phrasing might’ve been confusing No worries
Want results from more Discord servers?
Add your server
More Posts
where generated images are saved using nuxt-image ipx with Nuxt 3?I am optimizing images from an external endpoint using ipx, I need to setup persistence for these imHow to check if a composable exists ?I want to check if a composable exists in a component. With `import { myComposable } from '#imports'V-Calendar's DatePicker in FormGroup (Nuxt UI) with Yup validationHi ! I tried for a while yesterday to use the DatePicker component of V-Calendar, highlighted in thCustom directive stops working after upgrading from Vue 3.4.21 to 3.4.22I have been having a really bad time with minor Vue version upgrades with my nuxt app. The most receIs it possible for any env variables to be leaked from the nitro server package?After build I can see my db connection info from the env variable embedded into the node-server.mjs Adding a third party script to Nuxt websiteI'm currently trying to follow this guide: https://www.cookieyes.com/documentation/cookie-banner-on-Fetch Data even on page reload using custom Fetch ComposableI am trying to fetch data in a page. I am using a custom Fetch composable. But the fetch seems only After upgrading, computed props are slow and throwing call stack size errUpgrading from `nuxt 3.8.1` `vue 3.3.8` `vite 4.5.0` -> `nuxt 3.11.2` `vue 3.4.24` `vite 5.2.10` MuseFetch triggers on ssr while server: false ?I put console.log in my useFetch, and I can see that getCachedData get triggered twice while on ssr.[Solved]Iterator is undefined in V-forHello! I have a drop down that's supposed to change based on the choice of a radio button. This work