A route handler is the function a router calls when a route matches. It produces the information needed to render that destination. The handler is not the router: matching, replacing the current view, and updating browser cues remain separate responsibilities. section 10.0 section 11.4.2
Keep the return value small and predictable. In a simple router, each handler returns a title and a view that is a DOM Node. The router places that node in an outlet, updates the document title, marks active links, moves focus, and handles scroll where appropriate. section 11.1 section 11.6
A small handler contract
A route declared with addRoute(path, handler) can associate “/cart” with a handler returning { title: "Cart", view: cartNode }, where cartNode is a DOM Node. The handler supplies the result; the router decides when and how to display it. section 11.4.2 section 10.4.3
Return nodes rather than unsafe HTML strings. If a route loads data, account for cancellation and pending or error states, and distinguish a failed route from an unknown one. A small router need not add loaders, guards, or nested routes unless the application requires them. section 11.6 section 11.4.2

