handler-use

Attach default loaders, middleware, and parallels to handlers via handler.use in Rango routes.

Updated Nov 7, 2025
One-click install
npx skills add https://github.com/rangojs/rango --skill handler-use-rangojs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: handler-use
Source: https://github.com/rangojs/rango/tree/main/packages/rangojs-router/skills/handler-use
Command: npx skills add https://github.com/rangojs/rango --skill handler-use-rangojs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Handlers in a Rango route tree often need the same loader, middleware, or loading skeleton wired at every mount site, forcing repetitive use() callbacks across layouts and paths. This Skill explains how to attach defaults directly to a handler with handler.use so the handler becomes a self-contained, reusable unit. ## Core Features & Use Cases - Handler-attached defaults: Attach loader, middleware, loading, parallel, intercept, and other use items to a handler function or branded Static/Prerender/Passthrough definition via a .use callback. - Mount-site validation: The runtime validates handler.use items against per-mount-site allow lists (path, layout, parallel, intercept, response routes) and throws descriptive errors for disallowed items. - Composable parallel slots: Slot handlers carry their own loader, skeleton, and revalidation contract, so layouts declare only slot names; shared use broadcasts to all slots while slot descriptors scope items like loading() to one slot. - Use Case: A dashboard layout mounts @cart and @notifs parallel slots; each slot handler owns its loader and skeleton, so a second layout can reuse the same slots with zero re-wiring. ## Quick Start Show me how to attach a default loader and loading skeleton to a Rango handler using handler.use and mount it as a parallel slot.

Frequently Asked Questions about handler-use

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I attach a default loader to a Rango route handler?

Assign a .use callback to the handler function that returns an array containing loader(YourLoader). The loader then runs wherever the handler is mounted, and the handler reads the data with ctx.use(YourLoader) inside its body.

What is the difference between handler.use and explicit use() at a mount site?

handler.use provides the handler's defaults, while explicit use() at the mount site adds overrides. Items merge with handler.use first and explicit use second; accumulating items like middleware run from both, while last-write-wins items like loading() are replaced by the explicit one.

Which use items are allowed inside a parallel() slot in Rango?

Parallel slots allow only revalidate, loader, loading, errorBoundary, notFoundBoundary, and transition. Middleware and layout are not permitted; returning a disallowed item from handler.use throws a registration error naming the offending type and mount site.

How do I set a loading skeleton for only one parallel slot?

Use the slot descriptor form { handler, use } inside parallel() and put loading() in that descriptor's use callback. The shared parallel use() broadcasts to every slot, but slot-local use is the narrowest scope and wins for last-write-wins items like loading().

Can a JSX element handler have a .use callback in Rango?

No. A bare JSX element passed as a handler has no function to attach properties to, so .use cannot be added. Pass a function handler or a branded Static(), Prerender(), or Passthrough() definition and attach .use to that instead.

When is handler.use validated against mount-site rules?

Validation runs at registration or first match, not at handler definition time. The same handler mounted in a path() and an intercept() is checked against each mount site's allowed-types set when registered.