Understanding the islands architecture pattern for building performant web applications with minimal client-side JavaScript. Perfect for modern web development.
The islands architecture is a modern approach to building performant web applications by minimizing client-side JavaScript.
Islands architecture involves:
Create an island component in app/islands/Counter.tsx:
import { createIsland } from "honox/island";
export default createIsland({
Component: function Counter() {
const [count, setCount] = createSignal(0);
return (
<div>
<p>Count: {count()}</p>
<button onClick={() => setCount(count() + 1)}>
Increment
</button>
</div>
);
},
});
Use it in your route:
import Counter from "../islands/Counter";
export default createRoute((c) => {
return c.render(
<div>
<h1>My Page</h1>
<p>This is static content.</p>
<Counter client:load />
</div>
);
});
client:load only when neededclient:idle for non-critical interactivityIslands architecture provides an excellent balance between interactivity and performance.