All situations
2

The second Astro island needs the same cart.

Context stops at its root. A store doesn't.

ReactVue

Header island · React
const cart = useStore($cart)
return <span>Cart ({cart.length})</span>
$cart = atom([])
Catalog island · Vue
<script setup lang="ts">
const cart = useStore($cart)
</script>

<template>
  <button @click="addItem(product)">Add ({{ cart.length }})</button>
</template>

Separate bundles must share one copy of the store module.

npm install nanostores
Getting started →

React Context keeps growing →One state for several frameworks →