Skip to main content
InterviewHubPRO
Section Overview
Q16

Question 16 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

32%
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:
    typescript
    // src/stores/cart.ts
    import { atom } from 'nanostores';
    export const cartItems = atom<string[]>([]);
    
    Both the React island and the Svelte island can import and subscribe to cartItems. When the React button calls cartItems.set(...), the Svelte badge updates reactively!