Saltar al contenido
Skillpedia
Sitios e interfaces (frontend)7,6 mil · #13146

client-side-routing

Qué hace

Esta skill explica cómo añadir páginas a una app Agent-Native manteniendo montada la estructura compartida. La estructura incluye la barra lateral del agente y la navegación. Es para desarrolladores que añaden rutas a estas apps de React.

Cuándo usarla

  • ✓Cuando añades una página nueva a una app Agent-Native.
  • ✓Cuando la barra lateral del agente se recarga cada vez que el usuario cambia de página.
  • ✓Cuando necesitas elegir entre una ruta de diseño raíz y una ruta de diseño sin segmento.

Link de la skill

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

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-side-routing/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Puedes añadir una página nueva de informes a mi app sin que la barra lateral del agente se recargue al ir allí?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente monta la estructura compartida una sola vez por encima del punto de salida de las páginas, y usa una ruta de diseño sin segmento cuando algunas páginas son públicas y otras privadas.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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
Preguntas frecuentes

¿Por qué se recarga la barra lateral del agente?

Suele pasar cuando cada página se envuelve en su propio diseño, de modo que la estructura se vuelve a montar al navegar.

¿Qué es una ruta de diseño sin segmento?

Es una ruta padre que añade un diseño sin añadir una parte a la dirección web.

¿Qué framework se usa?

La skill indica que las apps usan React Router como aplicaciones de una sola página.

Detalles

Descripción original del autor

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

Popularidad

Estrellas en GitHub
7,6 mil
Posición en el ranking
#13146
Licencia
MIT
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas