layout

Define layout routes that wrap child routes with persistent UI shells in @rangojs/router.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @rangojs/router.

What problem does it solve? Sharing a persistent UI shell (navigation, sidebar, breadcrumbs) across nested routes in a React Server Components app requires layouts that survive navigation and coordinate data, loaders, and revalidation correctly. This Skill shows how to declare those layouts in @rangojs/router's code-first route tree. ## Core Features & Use Cases - Layout declaration: Wrap child routes with JSX elements, component functions, or context-aware handlers using layout() inside urls(). - Outlets and parallel routes: Render child content with <Outlet /> and named slots via <ParallelOutlet /> for dashboards and sidebars. - Orphan layouts and data flow: Attach layouts inside path() entries to read handler data via ctx.get() with safe action revalidation defaults. - Revalidation contracts: Control which segments re-render after Server Actions using revalidate() predicates shared between producer and consumer segments. - Use Case: Build a shop section where a persistent nav and cart sidebar wrap product, cart, and index pages, with the cart loader revalidating only when cart actions run. ## Quick Start Ask the AI to create a layout route in @rangojs/router that wraps your shop pages with a shared navigation shell and an Outlet for child content.

Frequently Asked Questions about layout

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

FAQPage Schema
How do I create a shared layout for nested routes in @rangojs/router?

Use layout() inside the urls() callback, passing a JSX element or component and a children callback containing path() entries. Child routes render through the <Outlet /> component imported from @rangojs/router/client.

How do layouts render child content with Outlet in Rango?

Import Outlet from @rangojs/router/client and place it where child routes should render inside the layout component. For parallel routes, use ParallelOutlet with a name prop matching the parallel slot key.

Can a layout read data set by a route handler in Rango?

Yes, an orphan layout declared as a child of path() can call ctx.get() to read values the route handler set with ctx.set(). The handler always executes before its children, and the whole entry revalidates together on actions by default.

Why does my layout not re-render after a Server Action?

Standalone layout() entries skip revalidation on actions by default because parent-chain segments are not re-run. Add a revalidate() predicate inside the layout's children, such as one checking ctx.isAction(), to opt the segment in.

How do I share revalidation logic between a layout and its child routes?

Define a named revalidation function, for example one returning ctx.isAction(addToCart) || undefined, and reuse it in revalidate() calls on both the producer and consumer segments. This keeps cross-entry data dependencies in sync.

Can a layout carry its own middleware and parallel routes?

Yes, attach a .use property to the layout handler returning middleware(), parallel(), or include() items. These defaults merge with any explicit use() declared at the mount site, with handler defaults applied first.