Skip to content
Skillpedia
Websites & UI (frontend)7.6k Β· #13146

client-side-routing

What it does

This skill explains how to add pages to an Agent-Native app while keeping the shared shell mounted. The shell includes the agent sidebar and navigation. It is for developers adding routes to these React apps.

When to use it

  • βœ“When you are adding a new page to an Agent-Native app.
  • βœ“When the agent sidebar reloads every time the user changes page.
  • βœ“When you need to choose between a root layout and a pathless layout route.

Skill link

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-side-routing/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-side-routing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œCan you add a new reports page to my app without the agent sidebar reloading when I navigate there?”

5 new skills a week. 1 minute to read.

How it works

The agent mounts the shared shell once above the page outlet, and it uses a pathless layout route when some pages are public and others are private.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Client-Side Routing

Rule

All templates are single-page apps using React Router. Navigation must not remount the app shell. The agent sidebar, document tree, and any other persistent chrome must survive route changes.

Why

If the shell unmounts on every navigation, the agent chat reconnects/reloads, destroying in-progress work and hammering the backend.

Hard Rule

The app shell (AgentSidebar + any top-level navigation) must be mounted ONCE, above the <Outlet />. Never wrap each page in its own <AppLayout> / <Layout>. React sees a different component at the outlet position on each nav and unmounts the entire subtree.

Two Correct Patterns

1. All routes need the shell

Mount <AppLayout> in root.tsx around <Outlet />:

// app/root.tsx
<AppLayout>
  <Outlet />
</AppLayout>

2. Mix of protected and public routes

Use a React Router pathless layout route:

app/routes/
  _app.tsx                  # renders <AppLayout><Outlet /></AppLayout>
  _app._index.tsx           # / β†’ under AppLayout
  _app.settings.tsx         # /settings β†’ under AppLayout
  _app.team.tsx             # /team β†’ under AppLayout
  book.$slug.tsx            # /book/:slug β†’ no layout (public)
  f.$.tsx                   # /f/* β†’ no layout (public form filler)

The _ prefix on _app.tsx makes it a pathless parent β€” it contributes the layout but no URL segment. Route files prefixed with _app. nest under it and share the layout instance across navigations.

Anti-Pattern

// ❌ BAD β€” each route wraps its own Layout, causing full remount on every nav
export default function Settings() {
  return (
    <AppLayout>
      <SettingsContent />
    </AppLayout>
  );
}

If a page needs per-route data (e.g. sidebar highlighting the active document), derive it inside the layout from useParams() / useLocation() β€” don't pass it as a prop through every route file.

Chat-First Routes

If / is a full-page chat such as AgentChatHome, keep the app shell mounted around it when possible so AgentSidebar URL sync and route warmup stay active. If the chat route intentionally lives outside the shell, add a tiny app-owned prewarm for the routes agents commonly open from that chat. In local dev, React Router can update the address bar before a cold Vite route chunk commits, which makes navigation look broken even when the URL is correct.

Adding a New Route

  • Pattern #1 (AppLayout in root.tsx): just render page content β€” nothing else.
  • Pattern #2 (pathless _app.tsx): name the file _app.<segment>.tsx for authed routes, or bare <segment>.tsx for public routes.

Related Skills

  • adding-a-feature β€” The four-area checklist referencing route layout patterns
  • context-awareness β€” Navigation state written on every route change
FAQ

Why does the agent sidebar reload?

It usually happens when each page wraps itself in its own layout, so the shell remounts on navigation.

What is a pathless layout route?

It is a parent route that adds a layout without adding a part to the web address.

Which framework is used?

The skill says the apps use React Router as single page apps.

Details

Original description by the author

How to add routes without remounting the app shell. Use when adding a new route, fixing agent sidebar reloads on navigation, or choosing between `root.tsx` layout and pathless `_app.tsx` layout patterns.

repo: BuilderIO/agent-native

Popularity

GitHub stars
7.6k
Ranking position
#13146
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills