Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Use a store (pinia) for all data or just for the shared data ?

Hello,

In a personal project, I have tried to manage all datas via the store (with pinia, but it could have been another store manager).

What's the better solution ?

  • manage all datas via the store ?

  • manager only the shared datas via the store ?

Is it for example a good idea to load in the store all the contents of the select / options fields so that I don't have to load them each time I open a form ?

What I noticed myself via this experience is that it's perhaps not useful to use a store to manage a form, but it's useful to open / close a modal form from different components. Furthermore it's probably interesting to use a store when I have to manage events between components, for example if I change the category of an object, using the store to fire this update can be useful to recalculate statistics automatically.

According to me, it seems heavy to manage all datas inside the store as it's similar to transfer all the business logic to the store and it's not its purpose.

Thanks for your opinion.

V

0 likes
3 replies
Respect's avatar
Respect
Best Answer
Level 3

Hello mr vincent15000 for my projects i'm using store for each model ex) productstore.js , contactStore.js, homestore.js

1 like
vincent15000's avatar

@Respect Finally I just use the store for shared data, I don't think that it's a good idea to overload the local memory with unused datas.

So I load the data for each page separately and when some datas are shared between several components, I use the store.

Please or to participate in this conversation.