Any questions? Get in touch: info@inspire-web.gr

Inspire Web

Inspire Web

Web Development & Digital Marketing

+30 6970671095
Email: info@inspire-web.gr

Inspire Web
41 Filonos St., Piraeus 185 31, Greece

Open in Google Maps
  • HOME
  • SERVICES
  • PROCESS
  • PORTFOLIO
  • BLOG
  • CONTACT
  • Ελληνικά
  • Home
  • Blog
  • Vue.js
  • Pinia in Vue 3: state management without the extra complexity
1 December 2026

Pinia in Vue 3: state management without the extra complexity

by Inspire Web / Tuesday, 01 December 2026 / Published in Vue.js, Web Development
Pinia in Vue 3: state management without the extra complexity

Every Vue application that grows reaches a point where data no longer fits inside a single component: the signed-in user, the shopping cart, list filters, notifications. That is when you need one central place for state. At Inspire Web we use Pinia for this: the library recommended by the Vue team itself, which has replaced Vuex in new projects.

Why Pinia instead of Vuex

Pinia keeps the same philosophy but removes the ceremony. There are no separate mutations, no nested modules, and TypeScript support feels natural without extra type declarations. Each store is a small, self-contained file, which makes the code easier for a team to read and maintain.

A store in ten lines

With the “setup” style, a store looks exactly like a component that uses the Composition API:

import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCartStore = defineStore('cart', () => {
  const items = ref([])
  const total = computed(() => items.value.reduce((s, i) => s + i.price * i.qty, 0))
  function add(product) { items.value.push({ ...product, qty: 1 }) }
  return { items, total, add }
})

A ref becomes state, a computed becomes a getter, and a function becomes an action. Nobody has to learn a second mental model.

What goes in a store and what does not

The most common mistake is putting everything into Pinia. The rule we follow:

  • In a store: data needed by many unrelated components (user, permissions, cart, settings).
  • Local to the component: form state, an open modal, the value of a search field.
  • In a composable: reusable logic that does not need to share one instance of the data.

Practices that prevent problems

  1. One store per functional domain. A giant “appStore” quickly becomes the new global state, with all its problems.
  2. Use storeToRefs when you destructure state or getters, so reactivity is preserved. Actions can be destructured normally.
  3. Keep API calls in actions (or in a separate service layer), so components stay simple and easy to test.
  4. Test with fresh stores. Creating a new createPinia() for each test means every test starts from a clean state.
  5. Persist sparingly. Save to localStorage only what truly needs to survive a refresh, and never sensitive data or tokens without careful thought.

Tooling and productivity

Integration with Vue Devtools gives you visibility into every store: you can see the state, its changes over time, and which action caused what. In SSR applications, for example with Nuxt, Pinia integrates without extra setup, which helps when the same project also has SEO requirements.

When you do not need it

In a small application or a simple website, provide/inject or a shared composable is often enough. The right architectural question is not “which library is popular”, but “how many parts of the application share this data, and how often does it change”.

Building an application with Vue?

Inspire Web designs and develops web applications and SaaS products with Vue.js, Spring Boot and modern, scalable architectures. If you would like us to look at your idea or review an existing application, get in touch.

Tagged under: JavaScript, Pinia, State management, Vue 3, Vue.js

What you can read next

Web accessibility: WCAG 2.1 and the European Accessibility Act in practice
Web accessibility: WCAG 2.1 and the European Accessibility Act in practice
Headless WordPress: when it pays to separate content from the frontend
Headless WordPress: when it pays to separate content from the frontend
REST API security: the 10 points we check in every penetration test
REST API security: the 10 points we check in every penetration test

Recent posts

  • Headless WordPress: when it pays to separate content from the frontend

    Headless WordPress: when it pays to separate content from the frontend

    What headless WordPress is, its pros and cons, ...
  • Publishing an app on Google Play and the App Store: the complete guide

    Publishing an app on Google Play and the App Store: the complete guide

    What you need to publish an app on Google Play ...
  • Elementor, Gutenberg or a custom theme? How we choose for each WordPress site

    Elementor, Gutenberg or a custom theme? How we choose for each WordPress site

    Comparing Elementor, Gutenberg (the block edito...

Facebook

Inspire Web

Categories

  • Android & iOS
  • Artificial Intelligence
  • Digital Marketing & SEO
  • Elementor
  • Java & Spring Boot
  • REST APIs
  • Vue.js
  • Web & Native Applications
  • Web Design
  • Web Development
  • WordPress & WooCommerce

ABOUT INSPIRE WEB

Technology & fresh ideas tailored to your needs!

We are a services agency specialising in Requirements Analysis & Design, Website Development, Web Development, Custom Applications and apps, Digital Marketing and Technical Support.

At Inspire Web we design and develop unique, impressive websites that inspire, deliver results and stand the test of time.

NEWSLETTER

Εγγραφείτε στο newsletter μας για να ενημερώνεστε άμεσα για τα νέα και τις προσφορές μας.

e-banner espa

CONTACT

Email: info@inspire-web.gr

Address
41 Filonos St., Piraeus 185 31, Greece

View on Google Maps

  • GET SOCIAL
Inspire Web

© Copyright 2026 Inspire Web. All rights reserved | Privacy Policy

TOP Skip to content
Open toolbar Accessibility Tools

Accessibility Tools

  • Increase TextIncrease Text
  • Decrease TextDecrease Text
  • GreyscaleGreyscale
  • High ContrastHigh Contrast
  • Negative ContrastNegative Contrast
  • Light BackgroundLight Background
  • Links UnderlineLinks Underline
  • Readable FontReadable Font
  • Reset Reset