Install pinia-react with your preferred package manager:
Create a pinia instance and call it once at the root of your application. This is essential for all stores to share the same global state container.
A Store is a container that encapsulates the global state (State), business logic for modifying the state (Actions), and readable data derived from the state (Getters) in an application. It allows any component in the application to access and modify shared data, thereby achieving cross-component communication and state synchronization.
A store should contain data that can be accessed by the entire application, such as themes, user login status, etc. Or if you have a complex interactive page with multiple components, each having its own state, this scenario can be considered for using a store to manage state and business logic to improve efficiency.
If the state is only used in the current page or component, and there is no need for communication or dependency, there is no need to create and manage a separate store.