vagejs 0.11: interactive React components

vagejs 0.11 lets a React component run in the browser when you mark it with client:load, client:visible or client:idle. Every other page still sends no JavaScript. Update with npm install vagejs@latest.

On this page
  1. What changed?
  2. Why does it matter?
  3. Where to go next

What changed?

In 0.10, React components became plain HTML at build time. In 0.11, you can also make one interactive, in an MDX page or a React layout:

<PriceCalculator client:visible pricePerSeat={12} />

The component is still turned into HTML first, so visitors see it straight away, and then it starts working in the browser: when the page loads, when it scrolls into view, or when the browser is idle.

Why does it matter?

Most of a content site never changes after it loads, but some parts need to react to a visitor: a price calculator, a filter, a small form. Before 0.11 that meant writing your own script. Now it's one word on a component, and only the pages that use one load JavaScript.

That JavaScript isn't hidden from you. Each page with an interactive component loads React, about 215 KB, and vage audit counts it against your JavaScript budget. vage check explains, by name, anything it can't turn into a working component.

Where to go next

Interactive components are React only for now. Vue components work in layouts, as HTML. The full list of changes is in the changelog.

Start with one command.
You'll have a site running in a minute.

npm create vagejs@latest my-site

Read the docsUse it with your AI assistant