0
0
Astroframework~10 mins

Choosing the right framework for each island in Astro - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Choosing the right framework for each island
Start: Identify UI parts
Decide if static or interactive
Static
Combine islands into page
Final page
This flow shows how to split a page into parts, decide which need interactivity, pick frameworks for those, and combine all into one page.
Execution Sample
Astro
const islands = [
  {name: 'Header', interactive: false},
  {name: 'Gallery', interactive: true, framework: 'React'},
  {name: 'Footer', interactive: false}
];
Defines page parts (islands) and marks which need interactivity and which framework to use.
Execution Table
StepIslandInteractive?Framework ChosenAction
1HeaderNoNoneRender as static HTML
2GalleryYesReactRender with React framework
3FooterNoNoneRender as static HTML
4CombineN/AN/ACombine all islands into final page
💡 All islands processed and combined into final page
Variable Tracker
VariableStartAfter 1After 2After 3Final
islands[Header, Gallery, Footer][Header, Gallery, Footer][Header, Gallery, Footer][Header, Gallery, Footer][Header, Gallery, Footer]
renderedParts[][Header as static HTML][Header static, Gallery React][Header static, Gallery React, Footer static][All combined into page]
Key Moments - 2 Insights
Why do some islands have no framework chosen?
Because those islands are static and don't need interactivity, so rendering plain HTML is enough (see execution_table steps 1 and 3).
How do we decide which framework to use for an interactive island?
We pick the framework best suited for that island's needs, like React for complex UI (see execution_table step 2).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, which island is rendered with React?
AHeader
BGallery
CFooter
DCombine
💡 Hint
Check the 'Framework Chosen' column in step 2
At which step do we combine all islands into the final page?
AStep 1
BStep 2
CStep 4
DStep 3
💡 Hint
Look for the 'Combine' action in the execution table
If the Gallery island was not interactive, what would change in the execution table?
AGallery would be rendered as static HTML
BGallery would still use React
CFooter would use React
DHeader would become interactive
💡 Hint
Refer to how non-interactive islands are handled in steps 1 and 3
Concept Snapshot
Split page into islands by UI parts
Decide if each island is static or interactive
Render static islands as plain HTML
Use suitable framework for interactive islands
Combine all islands into one final page
Full Transcript
Choosing the right framework for each island means breaking a webpage into smaller parts called islands. Each island is checked if it needs interactivity. If not, it is rendered as simple static HTML. If yes, we pick a framework like React to render that island. Finally, all islands are combined to form the complete page. This approach helps optimize performance by only loading frameworks where needed.