On the other hand, when defining a setup store, you can use almost any composable since every property gets discerned into state, action, or getter:
```ts
-import { defineStore, skipHydrate } from 'pinia'
+import { defineStore } from 'pinia'
import { useMediaControls } from '@vueuse/core'
export const useVideoPlayer = defineStore('video', () => {
In [Option Stores](#option-stores), you need to define a `hydrate()` function. This function is called when the store is instantiated on the client (the browser) when there is an initial state available at the time the store is created. The reason we need to define this function is because in such scenario, `state()` is not called.
```ts
-import { defineStore, skipHydrate } from 'pinia'
+import { defineStore } from 'pinia'
import { useLocalStorage } from '@vueuse/core'
export const useAuthStore = defineStore('auth', {
When it comes to _setup stores_, you can simply use one of the stores **at the top** of the store function:
```ts
+import { defineStore } from 'pinia'
import { useUserStore } from './user'
+import { apiPurchase } from './api'
export const useCartStore = defineStore('cart', () => {
const user = useUserStore()
})
function purchase() {
- return apiPurchase(user.id, this.list)
+ return apiPurchase(user.id, list.value)
}
return { summary, purchase }
```js
import { defineStore } from 'pinia'
import { useUserStore } from './user'
-
+import { apiOrderCart } from './api'
+
export const useCartStore = defineStore('cart', {
actions: {
async orderCart() {
```js{7-8,11-13}
import { defineStore } from 'pinia'
import { useUserStore } from './user'
-
+import { apiOrderCart } from './api'
+
export const useCartStore = defineStore('cart', {
actions: {
async orderCart() {
These are some snippets that I use in VS Code to make my life easier.
-Manage user snippets with <kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>P</kbd> / <kbd>⇧</kbd> <kbd>⌃</kbd> <kbd>P</kbd> and then `Snippets: Configure User Snippets`.
+Manage user snippets with <kbd>⇧ Shift</kbd>+<kbd>⌘ Command</kbd>+<kbd>P</kbd> / <kbd>⇧ Shift</kbd>+<kbd>⌃ Control</kbd>+<kbd>P</kbd> and then `Snippets: Configure User Snippets`.
```json
{