Options — Pinia, Vuex, provide/inject.
Pinia:
1const useStore = defineStore("store", () => {2 const state = ref(initial)3 const getter = computed(() => state.value)4 function action() { state.value++ }5 return { state, getter, action }6})
provide/inject:
1// Parent2provide("state", reactive({ count: 0 }))34// Child5const state = inject("state")
Key: Pinia for global, provide/inject for scoped.