A Store is defined using defineStore(). Its first parameter is a unique ID that Pinia uses to identify the store.
Store IDs must be unique within a Pinia instance. Duplicate definitions warn in development; use a distinct ID for each Store.
It's recommended to name the exported hook starting with use and ending with Store (e.g., useUserStore, useCartStore). This follows standard React Hook conventions.
You define a store's configuration by passing an options object with state, getters, and actions properties.
After defining the store, simply import and call its hook in your component.
Component Hooks use the nearest PiniaProvider, then active Pinia. Plain accessors do not read React Context; pass getCounterStore(pinia) in multi-instance services. See Stores outside components for instance lifetime and Next.js for request snapshots. The simple single-root setup does not need a Provider.