Questions tagged [pinia]

Pinia stands out as a cutting-edge JavaScript store library designed specifically for Vue.js, enabling seamless sharing of state data among various components and pages.

What is the preferred approach: modifying the Pinia state within actions or directly within the component?

One challenge I've encountered involves a function within my Pinia store: async function getCurrentUser(){ let user: User | undefined = undefined; if (auth.currentUser?.uid) { user = await getUserById(auth.currentUser.uid) state.va ...

Bring in dynamic Pinia store and Vue component that rely on a particular reference

Currently, I am in the process of developing an application using Quasa V2 framework, vue, vite, pinia, and format. One of the components in my app is basicList.vue, which retrieves its control attributes and properties from a pinia store named oTable. By ...

Testing Vue Component with Cypress revealed that the function getActivePinia was triggered without an active Pinia instance

Below are the code snippets I'm working with: Test.vue <template> <button v-show="store.common == 'hi'" @click="func"> hello world </button> </template> <script setup> import {mainStore} from './i ...

Exploring the best practices for loading state from local storage in VueJS/NuxtJS by leveraging the "useLocalStorage" utility

When attempting to utilize useLocalStorage from pinia, I am encountering an issue where the data in the store's state is not fetched from local storage and instead defaults to the default value. Below is the code snippet from my store method: import { use ...

how to switch page direction seamlessly in vue without triggering a page refresh

I'm looking to update the page direction in Pinia whenever a value changes, and while my code is functioning correctly, it reloads the page which I want to avoid. Take a look at my App.vue <script setup> import { useaCountdownStore } from "./st ...

How do I test Pinia by calling one method that in turn calls another method, and checking how many times it has been called

As I embark on my journey with Vue 3 and Pinia, a particular question has been lingering in my mind without a concrete answer thus far. Let's delve into the crux of the matter... Here's an example of the store I am working with: import { ref, computed } f ...

Using vue-router within a pinia store: a step-by-step guide

I'm currently setting up an authentication store using Firebase, and I want to direct users to the login/logged page based on their authentication status. My goal is similar to this implementation: https://github.com/dannyconnell/vue-composition-api-cours ...

Tips for correctly retrieving the current state from a pinia store to use as an argument for an asynchronous function

I am currently facing an issue with a simple counter store in pinia. The counter itself updates and displays correctly on the page, however, when trying to use the count in a specific function, it does not reflect the updated state of the counter store. Ho ...

Leveraging OnMounted and Axios Requests in Pinia

I am currently developing a website that showcases a range of products with dedicated product pages. However, I am facing challenges in determining the optimal sequence for loading data. While I could make an axios call and pass the data as a prop to subse ...

Maintaining pinia stores through nuxt 3 for long-term storage

I tried following the instructions provided in this pinia persisted state plugin guide, but I am encountering an issue where my states reset on page refresh. Could there be a problem with my configuration? // nuxt.config modules: [ [ "@pinia/nux ...

After assigning a value, the property within the Pina store is now returning as an empty object

In my accountsList.vue file, I have a script where I've commented out a lot of code for a serious refactor. The "balance" variable is properly set and has a value, as confirmed by checking it. <script setup> import Account from "@/Pages/Partials ...

Pinia is having trouble importing the named export 'computed' from a non-ECMAScript module. Only the default export is accessible in this case

Having trouble using Pinia in Nuxt 2.15.8 and Vue 2.7.10 with Typescript. I've tried numerous methods and installed various dependencies, but nothing seems to work. After exhausting all options, I even had to restart my main folders on GitHub. The dependen ...

Experience the power of VueJS 3 with Pinia, all without the need

I've hit a wall. Despite scouring documentation and countless google searches, I can't seem to find the answer to this straightforward query: how do I install/import PINIA in a VUE application? Let's consider a basic VUE app: <div id=&qu ...

Using Vue's useStorage (usevue) ensures that each time it is initialized, it begins with a clean slate instead of

My app was developed using vitesse-nuxt3, and everything is working smoothly except for my attempt to use LocalStorage with the help of vueuse. Component: <script setup lang="ts"> const { test } = useTestStore() </script> <templa ...

Exploring the world of Vue and Pinia: managing and accessing data like

While delving into Vue and Pinia, I encountered a data management issue on the user side. On my main page, I showcase categories and auction items. However, upon navigating to a specific category in the catalog, the data for auction items remains in the st ...

Retrieving the internationalization (i18n) locale language from the Pinia store

I am attempting to retrieve the value of the i18n locale language from my pinia store, however, an error is occurring Uncaught Error: [ ...

How can I correctly implement a pinia store within another pinia store in Vue 3?

Within my todosStore pinia store, I am implementing CRUD operations against the backend. To achieve this functionality, I require a separate pinia store called bannerStore for updating the message and class of the bootstrap alert component in the template. ...

What determines which code Nuxt3 will run on the server-side versus the client-side?

Looking to dive into the world of Nuxt3. As far as I know, it employs universal rendering, blending elements of CSR and SSR. But before embarking on this journey, a couple of queries are on my mind. How does Nuxt3 differentiate between client-side and s ...

Using TypeScript with Vue and Pinia to access the store

Is it necessary to type the Store when importing it to TypeScript in a Pinia Vue project? // Component <p>{{ storeForm.firstName }}</p> // receiving an error "Property 'storeForm' does not exist on type" // Store ...

Vue 3 Single Page Application. When selecting, it emits the language and the contentStore does not update the content exclusively on mobile devices

My Vue 3 Single Page Application is built on Vite 4.2 and TypeScript 5.02. When I click to select a language, it emits lang.value and in the parent component App.vue, contentStore should update the content. It works flawlessly on my Linux Ubuntu desktop i ...

Utilizing Vue.js global variables within a Pinia store: a step-by-step guide

I am currently working on a Vue.js 3 project where I need to utilize a global axios instance in some .vue components and also in a pinia store. Within my main.js file, I have configured axios globally like so: const axiosInstance = axios.create({ base ...

With Vue 3 Pinia, values fetched from an API within a Pinia store cannot be statically assigned; they will always be reactive

I have a frontend built with vue3 and using pinia as the store. I am setting it up as shown below: export const useShopStore = defineStore( "shop", () => { const state = reactive({ data: { fruits: [], owners: [] ...

Leverage Pinia store in Vue helper functions

I have been working on my Vue.js application and I am looking to implement some helper functions that will utilize a Pinia store within the app. These functions need to be accessible by multiple components. Should I define these helper functions directly ...

I am interested in incorporating pinia state management into my Vue 3 project

I'm currently working on implementing pinia state management in Vue 3, but I've encountered the following error: Module not found: Error: Can't resolve 'src/stores/cart' in 'C:\Users\Ali Haider\theme-project&b ...

What is the correct way to handle the return value of an useAsyncData function in Nuxt 3?

How can I display the retrieved 'data' from a useAsyncData function that fetches information from a pinia store? <script setup lang="ts"> import { useSale } from "~/stores/sale"; const saleStore = useSale(); const { da ...

What are the advantages of choosing Pinia/Vuex instead of the traditional approach using service classes?

Pinia/Vuex Pinia/Vuex and Redux share a common goal of being the "single source of truth", where application data is stored in one or multiple stores accessible from anywhere. An example of a Pinia store: export let useProductsStore = defineStore('produc ...

Optimal approach for changing state in VueJs 3

While exploring the Pinia documentation, I came across a method to modify the state directly using ...mapWritableState or store.$patch(). However, I have always been taught to avoid direct state modification and instead use 'actions' in my code. ...

When working with Vue JS, which is more performant and preferable to use: making direct changes to state in Pinia or using $patch()?

Hey guys, I've been working with Pinia and Vuejs 3, and I'm curious about the performance impact of using $patch(). Can anyone shed some light on this? What is considered the best practice when it comes to this situation? For instance, take a l ...