All of the guide

Frames

A Turbo Frame is a part of a page that loads and navigates by itself. Links and forms inside it replace only the frame.

The example's stats panel loads once it scrolls into view (routes/index.tsx):

<turbo-frame id="stats" src="/stats" loading="lazy">
  <span class="loading loading-dots"></span>
</turbo-frame>

/stats is an ordinary page. When a frame asks, the request carries the header Turbo-Frame: stats, and the route answers with only the frame. A plain visit gets the whole page around it (routes/stats.tsx):

export const GET = defineHandler(async (c) => {
  const stats = <Stats count={await countMessages()} />;
  if (frameRequest(c) === "stats") return c.html(stats);
  return c.html(<Layout c={c} title="Stats">{stats}</Layout>);
});

The answer must contain a <turbo-frame> with the same id. Turbo would take it out of a whole page too, but answering with just the frame saves the work.

A region that is only changed by streams does not need to be a frame. An element with an id is enough.

Reference: https://turbo.hotwired.dev/handbook/frames

Check

curl -H 'Turbo-Frame: stats' https://hotwire.localhost:5173/stats returns one <turbo-frame id="stats"> and nothing else.

When it does not work

Symptom Cause
"Content missing" in the frame The answer has no <turbo-frame> with that id
A link inside a frame does nothing It goes to a page without that frame; add data-turbo-frame="_top"
The frame never loads No src, or loading="lazy" on a frame that never scrolls into view