# Composing Stores
-Composing stores is about having stores that use each other and there is one rule to follow:
+Composing stores is about having stores that use each other, and this is supported in Pinia. There is one rule to follow:
If **two or more stores use each other**, they cannot create an infinite loop through _getters_ or _actions_. They cannot **both** directly read each other state in their setup function:
})
```
-## Nested stores
+## Nested Stores
-Note that if one store uses another store, **there is no need to create a new store in a separate file**, you can directly import it. Think of it as nesting.
-
-You can call `useOtherStore()` at the top of any getter or action:
-
-```js
-import { useUserStore } from './user'
-
-export const cartStore = defineStore('cart', {
- getters: {
- // ... other getters
- summary(state) {
- const user = useUserStore()
-
- return `Hi ${user.name}, you have ${state.list.length} items in your cart. It costs ${state.price}.`
- },
- },
-
- actions: {
- purchase() {
- const user = useUserStore()
-
- return apiPurchase(user.id, this.list)
- },
- },
-})
-```
+Note that if one store uses another store, you can directly import and call the `useStore()` function within _actions_ and _getters_. Then you can interact with the store just like you would from within a Vue component. See [Shared Getters](#shared-getters) and [Shared Actions](#shared-actions).
## Shared Getters