React components in articles

Embed interactive React components in MDX articles, with islands that hydrate only when needed.

This post is also available in বাংলা.

The site renders to plain static HTML, but any MDX article can embed a React component as an interactive island. Only the component you mark with a client:* directive ships JavaScript; the rest of the page stays static.

Try it

Drag the sliders to estimate how long a download takes at a given connection speed. The component is hydrated when it scrolls into view.

Download time estimator

Estimated time: 13 min 20 s

Add your own component

Write a .tsx component and keep it in src/components/react/ when several articles share it, or next to the article in its bundle when only one uses it.

src/components/react/Hello.tsx
import { useState } from 'react';
export default function Hello({ name = 'world' }: { name?: string }) {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Hello, {name}! Clicked {count} times.
</button>
);
}

Import it in an .mdx article with the @components alias and add a client directive:

import Hello from '@components/react/Hello';
<Hello client:load name="reader" />

Choosing a client directive

DirectiveHydratesUse it for
client:loadImmediately on page loadControls visible at the top of the article
client:idleWhen the browser is idleLower-priority interactive widgets
client:visibleWhen scrolled into viewCharts and widgets further down the page
client:only="react"In the browser only, no server renderComponents that need browser-only APIs
no directiveNever; static HTML onlyComponents that only display content

Pass lang to components that show text so they can match the article language, and use Intl.NumberFormat for numerals so Bengali and English readers each see their own digits.

Xerobi Team

Editorial team

The people behind Xerobi, writing about connectivity, payments and the software that runs them.

MarkdownContent management

Search articles

Recent articles

Meet BlogGPTBrowsing and search: discover articles through conversationContent organization: files, languages and assetsReact components in articlesMarkdown typography: text, tables and codeArticle enhancements: callouts, math, diagrams and lightboxes

Keyboard shortcuts

Search articles
Ctrl+K
Toggle sidebar
Ctrl+Shift+S
Home
Ctrl+Shift+O
Focus search input
Shift+Esc
Keyboard shortcuts
Ctrl+/

Blog statistics

Articles
11
Characters
14,372
Days online
1,056
Language
bn / en
First publication
Jul 22, 2025
Latest update
Oct 16, 2026
Average length
1,307
Average interval
45.1 days / article

Publishing in the past year

MWFDecJanFebMarAprMayJunJulAugSepOctNov

Public articles in the site timezone. Darker cells mean more posts.

Recent article lengths