Cross-Framework State Sharing
Watch React, Vue, and Svelte components communicate seamlessly through shared state. Add items with React, manage them with Vue, and checkout with Svelte.
How It Works
Products
React ComponentsAstro T-Shirt
Comfy cotton tee with Astro logo
Rocket Mug
Start your day with rocket fuel
Islands Cap
Partial hydration, full style
Zero JS Hoodie
Ships with zero JavaScript
Component Socks
Keep your feet framework-agnostic
Build Time Bottle
Hydration when you need it
Shopping Cart
VueYour cart is empty
Add items using the React cards above
Checkout
SvelteThis Svelte component reads cart state set by React and Vue
The Magic Behind It
import { atom, computed } from 'nanostores';
export const cartItems = atom<CartItem[]>([]);
export const cartTotal = computed(cartItems, (items) =>
items.reduce((sum, i) => sum + i.price * i.quantity, 0)
);
export function addToCart(item: CartItem) {
cartItems.set([...cartItems.get(), item]);
} import { addToCart } from '../stores/cart';
function ProductCard({ product }) {
const handleAdd = () => {
addToCart({
id: product.id,
name: product.name,
price: product.price,
framework: 'react',
});
};
return <button onClick={handleAdd}>Add</button>;
} <script setup>
import { useStore } from '@nanostores/vue';
import { cartItems, cartTotal } from '../stores/cart';
const items = useStore(cartItems);
const total = useStore(cartTotal);
</script>
<template>
<div v-for="item in items">{{ item.name }}</div>
<span>Total: {{ total }}</span>
</template> <script>
import { cartItems, clearCart } from '../stores/cart';
let items = $state([]);
$effect(() => {
return cartItems.subscribe(v => items = v);
});
</script>
<button onclick={() => clearCart()}>
Clear {items.length} items
</button> Why This Matters
Team Flexibility
Different teams can use their preferred framework. A React team's components work alongside a Vue team's components.
Gradual Migration
Migrate from one framework to another incrementally. No big bang rewrites— just replace components one at a time.
Best Tool for the Job
Use React for complex forms, Vue for dashboards, Svelte for animations. Pick the right tool for each component.