router-setup

Configure a type-safe React Server Components router with createRouter and URL patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up a React Server Components router involves many moving parts: route trees, layouts, loaders, caching, error boundaries, and deployment concerns like sub-path hosting and CSP nonces. This Skill provides the patterns and configuration reference to bootstrap a Rango router correctly from the start. ## Core Features & Use Cases - Router Bootstrapping: Create a router with createRouter, a Document component, and Django-style urls() route definitions with named, type-safe routes. - Route Tree Composition: Nest layouts, parallel routes, loaders, loading skeletons, cache policies, middleware, and error/not-found boundaries in one declared tree. - Deployment Configuration: Configure basename sub-path deployment, cache stores, SSR streaming policy, telemetry sinks, CSP nonces, and connection warmup for platforms like Cloudflare Workers. - Use Case: You are scaffolding a new Rango app on Cloudflare Workers and need a router with a root layout, cached blog routes with loaders, a 404 page, and per-request cache configuration wired to the worker's fetch handler. ## Quick Start Ask the AI to create a Rango router with createRouter, a Document component, and a urls() route tree containing a home page and a blog route with a loader.

Frequently Asked Questions about router-setup

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

FAQPage Schema
How do I create a router with createRouter in Rango?

Call createRouter with a document component and a urls() route tree, then export the router. The urls() callback provides DSL functions like path, layout, loader, and cache to declare named routes, and the router exposes a fetch method for handling requests.

How do I define routes with layouts and loaders in Rango?

Use the urls() callback DSL: path() defines a route, layout() wraps child routes, and loader() and loading() attach data fetching and skeletons. Routes get names for type-safe reverse() calls, and groups can be composed with include() or code-split with an async import provider.

Does Rango router support deployment under a sub-path?

Yes, set the basename option in createRouter and all routes, reverse() calls, Link components, redirects, and middleware patterns are automatically prefixed. Route names stay unprefixed, but the raw href() helper does not apply the basename.

Can I use the Rango router with Cloudflare Workers?

Yes, export a worker fetch handler that calls router.fetch with the request, env, and ctx. For per-request caching, pass a cache function to createRouter that receives env and ctx and returns a CFCacheStore instance.

How does notFound() handling work in Rango routes?

Calling notFound() in a handler or loader triggers a fallback chain: nearest notFoundBoundary in the route tree, then defaultNotFoundBoundary, then the notFound component, then a built-in heading. Loader-thrown 404 status is deterministic only when the loader is registered with ssr: false.