GitHub
Color scheme

Islands in MDX

A sortable table and a chart in an Astro article, each an island with one hydration rule and a measured cost.

2 min read

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).

Deploys per week
142
181
173
221
192
251

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

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; use load="idle" or client:idle above 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/.