All of the guide

Pages

A page is a file in routes/, Void's file routes: the file's path is the address, and the file exports a handler for each method it answers. routes/about.tsx answers GET /about:

export const GET = defineHandler((c) =>
  c.html(
    <Layout c={c} title="About">
      <About theme={chosenTheme(c)} />
    </Layout>,
  ),
);
File Answers
routes/index.tsx /
routes/messages/new.tsx /messages/new
routes/messages/index.tsx /messages (its POST: Forms)
routes/account/passkeys/[id]/edit.tsx /account/passkeys/…/edit, the id from c.req.param("id")

defineHandler is Void's, and c is Hono's context. A page's own HTML is in its file, under the handler (About); what several pages use is a component in src/components/, and their other code is in src/. So a folder in routes/ is a part of the app, and taking one out takes its addresses out. Void's routing guide has the rest: catch-alls, folders that group files without changing the address, middleware for one route.

The components are Hono JSX: it looks like React, but it renders to an HTML string on the server and never runs in the browser. So write class (not className), plain attributes such as data-controller, and custom elements such as <turbo-frame>. A list needs no key.

Queries and headers come from Hono's context too: c.req.query("q"), c.req.header("Turbo-Frame"). A GET never changes anything, because Turbo prefetches links when the pointer hovers over them.

The layout

src/components/layout.tsx renders the document around every page. It does four things that Turbo and the first paint depend on:

The top-level pages are one list, in src/components/nav.tsx, drawn three ways:

Where What shows them Made of
A browser, wide daisyUI's navbar, the pages in a menu menu-horizontal Navbar, hidden below the sm breakpoint
A browser, phone-sized daisyUI's dock, a bar fixed to the bottom, an icon and a label each Dock, shown only below sm; the viewport has viewport-fit=cover so it clears the iPhone's home bar
The phone apps Native tabs, each with its own stack SceneDelegate.swift and MainActivity.kt (Hotwire Native)

They are plain links, so Turbo Drive follows them like any other. The server marks the page the request is for: menu-active or dock-active shows it, and aria-current="page" says it. The bars are not data-turbo-permanent: Turbo would keep the first page's bar, and its mark with it. A new top-level page is an entry in pages and a tab in each app.

This guide, on the site

The app shows this guide: /guide is its first page and /guide/<page> each other one (routes/guide/), in the app's layout, linked from the navbar and from the About page. src/guide.ts reads a page's markdown where it is published, on GitHub, as the repository's main branch has it, and makes it HTML with marked, with the ids on headings that GitHub gives them. So the site shows the guide as it is now, without a deploy, and a copy of the example carries no file of the guide's. Tailwind's typography plugin styles it (prose).

A link in a page goes where it should from the site (guideHref): sign-in.md#passkeys to /guide/sign-in#passkeys, and a file that is no page of the guide (../example/auth.ts, a skill) to GitHub. So pages link each other as files in one folder, which works on GitHub, in the installed plugin, and here. Cloudflare keeps GitHub's answer for five minutes; when GitHub does not answer, the page says where the guide is, with 502. An app with a guide of its own changes guide in that file; one without takes the file, the routes and the two links out.

The guide is no tab of the phone apps, so it is not in pages: an app opens it from the About page, as a screen on that tab's stack.

daisyUI has more for navigation, all plain HTML that Turbo needs nothing for: breadcrumbs, tabs (with a Turbo Frame, the tab's content loads without the rest of the page), pagination, and drawer for a side menu.

Which file answers a request

Request Answered by
A path that has a file in routes/ That file's handler for the method: a page, a form, a frame, JSON, a download, a webhook, the live stream
A path that has a file in public/ The file, as it is
Any other path under /api, or whose last part has a dot (/report.csv) Void, with a plain 404
Any other path src/main.ssr.tsx, Void's own renderer: the "not found" page, with 404

Void gives the bundle's tags to that renderer alone, which is why the layout makes its own. src/main.ssr.tsx and src/main.client.ts go together: with both, Void builds the browser's bundle.

Turbo Drive

Every link and form on the page goes through Turbo Drive. Turbo fetches the next page, replaces <body> and merges <head>, so the JavaScript and CSS stay loaded. You do not write anything for this. What it asks of you:

See the Turbo handbook: https://turbo.hotwired.dev/handbook/drive

Check

curl https://hotwire.localhost:5173/about returns the page, on a dev server with its styles in <head> (<style data-vite-dev-id=…>). In a browser, set window.mark = 1 in the console, follow a link, and window.mark is still 1 afterwards: Turbo swapped the page instead of reloading it. flows/navigation.yaml checks that the links reach their pages, in a browser and as the tabs of both apps, and vp test that the navbar and dock mark the page they are on.