Ivaylo Gerchev
Feb 24, 2024 ⋅ 16 min read

Leveraging Pinia to simplify complex Vue state management

Ivaylo Gerchev All things are difficult before they are easy.

Recent posts:

Leveraging Wasp For Full-Stack Development

Leveraging Wasp for full-stack development

Learn how the Wasp, Web Application Specification, framework simplifies full-stack development by offloading repetitive code tasks.

Wisdom Ekpotu
May 27, 2024 ⋅ 11 min read
Developing Web Extensions With Wxt

Developing web extensions with the WXT library

Browser extensions are an important part of the web ecosystem. They make our lives easier and enhance our web browsing […]

Debjyoti Banerjee
May 24, 2024 ⋅ 8 min read
Bulma Css Adoption Guide: Overview, Examples, And Alternatives

Bulma CSS adoption guide: Overview, examples, and alternatives

Explore how Bulma CSS simplifies frontend development with its ease of use and customizable, responsive, pre-designed UI elements.

Timonwa Akintokun
May 23, 2024 ⋅ 10 min read
Using Mountaineer To Develop A React App With Python

Using Mountaineer to develop a React app with Python

Develop a React app with Python using the Mountaineer framework for building a simple app with integrated your frontend and backend database.

Rosario De Chiara
May 23, 2024 ⋅ 7 min read
View all posts

17 Replies to "Leveraging Pinia to simplify complex Vue state management"

  1. I am really happy with your tutorial and about your patient to write details. It’s really helpful for us. Please write this type of article further.

  2. Thanks for the tutorial. This lines concern me – is it good practice to save the password unencrypted in the localStorage?

    user.authdata = window.btoa(username + ':' + password);


    // store user details and basic auth data in local storage to keep user logged in between page refreshes

    localStorage.setItem('user', JSON.stringify(user));

  3. I have problem with PostView.vue. fetchPost(to.params.id) is call only when i refresh page or first load, but when i click on any link with /post/:id never fire fetchPost(to.params.id) and get new post. When i change PostView.vue in script setup to:

    onBeforeRouteUpdate(async (to, from) => {
    if (to.params.id !== from.params.id) {

    Its OK. Where is problem?


  4. But the problem with this approach is that, imagine you want to access the posts state in multiple components, then you’d have to call the fetch function from pinia store in all these components (which is not DRY). We want a way to fetch the data directly from the store once it is created and before any component using it mounted or even created.

Leave a Reply