createGlobalState

Keep states in the global scope to be reusable across Vue instances.

store.js
import { createGlobalState, useStorage } from '@vueuse/core'

export const useVueUseStore = createGlobalState(() => useStorage('vueuse-local-storage-counter', 0))

Counter.vue
<script setup>
const count = useVueUseStore()
</script>

<template>
  <div>
    <button @click="count++">
      Count is:
      {{ count }}
    </button>
    <button v-if="count" @click="count=0">
      Reset
    </button>
  </div>
</template>