Guides
Islands in MDX
A sortable table and a chart in an Astro article, each an island with one hydration rule and a measured cost.
On this page
Two parts need React in the browser: a table the reader sorts and pages, and a chart that measures its box. Both are MDX tags that take plain data, so Astro can carry them into an island. Everything else on the page stays static.
A sortable table
Add interactive to the DataTable tag. The page is rendered as HTML first and hydrated when the table scrolls into view (client:visible).
| 14 | 2 | |
| 18 | 1 | |
| 17 | 3 | |
| 22 | 1 | |
| 19 | 2 | |
| 25 | 1 |
A chart
A chart measures the box it draws in, so the Chart tag renders on the client: client:only="react". Until it arrives the page shows the same card, loading, which is as tall as the finished one at any width, so nothing below it moves. Pass load="visible" to render it on the server and hydrate it in view once a chart kind’s server picture matches the browser’s.
Deploys per week
Deploys per week
The rule and the cost
The first island on a page brings React, react-dom and Astro’s island runtime. Each further island costs what its part adds. The numbers are the Astro matrix’s, gzip.
- Put an island below the fold on
client:visible; useload="idle"orclient:idleabove it. - One island per part is fine: React ships once per page.
- A part that needs more than data (custom marks, linked readouts) is your own island in
src/islands/.