Astro Islands & SSR (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How do independent Islands communicate with each other (Nano Stores)?
senior LevelCode ExampleSystem Design
In Simple Words: Because islands run in isolated component trees (e.g. a Svelte Header and a React Cart modal):
- Nano Stores (
nanostores): A lightweight (<1KB), framework-agnostic state manager:Both the React island and the Svelte island can import and subscribe totypescript// src/stores/cart.ts import { atom } from 'nanostores'; export const cartItems = atom<string[]>([]);cartItems. When the React button callscartItems.set(...), the Svelte badge updates reactively!