docs(renderers): document building a custom renderer end to end

Merged
KI
12d ago
+743-1

Problem

The renderer contract lives in sections of the Renderers overview, which is written for people choosing among the official renderers. Someone writing a renderer for another UI library has to piece it together from that summary, the bring-your-own-renderer blog post, and the example's source.

Change

  • New page, /docs/renderers/custom, in build order:
    • what the renderer owns and how Farm uses it
    • package layout, and every descriptor field
    • the server, client, and Vite modules, with required and optional exports
    • streaming, the per-runtime overrides, and the error rules before and after output
    • hooks over the @farm.js/core/renderer-client stores, server functions in the browser, action forms, and a Link built on resolveLinkAttributes()
    • a custom file format, function and async components, and route updates
    • the contract types, the @farm.js/renderer-tests suites, and limits
  • Every claim was checked against packages/farm/src. The page also covers details the overview leaves out:
    • Development creates the Vite plugin once with ssr: true for both graphs. A production build creates one per graph.
    • Hot updates have no hook in the renderer contract and come from the library's Vite plugin. Without one, saving a component reloads the page and resets all state. This was checked on the leaf example under farm dev: the document was replaced and the page's and layout's counters went back to 0.
    • The router store reads the request's URL on the server. This depends on #3131. On main today it reads /, so merge #3131 first.
  • submitRendererActionForm is marked as shipping in the release after 0.1.81 (#3117 landed after the 0.1.81 release commit).
  • The page is in the sidebar under Renderers → Custom and on the docs index. The Renderers overview links to it from two places.

Safety and compatibility

Docs only. The Renderers overview keeps every section and anchor. Published READMEs (@farm.js/renderer-tests), the blog, and core's missing-export error link to #renderer-modules and #renderer-capability-contract.

Verification

  • pnpm --dir docs exec farm generate, then farm generate --check: up to date. farm.d.ts gains the 3 expected route lines.
  • pnpm docs:check-navigation: 115 visible pages covered.
  • pnpm exec oxfmt --check on the four changed docs files: clean.
  • farm dev in docs, with the page loaded in Chrome at 1440×900 and 390×844: no horizontal overflow and no page errors.

Not run: pnpm docs:build.

Documentation and release

This PR is the documentation. No packages change.