Pular para o conteúdo
Skillpedia
Sites e telas (frontend)7,6 mil · #13146

client-side-routing

O que ela faz

Esta skill explica como acrescentar páginas a um aplicativo Agent-Native mantendo a estrutura compartilhada montada. A estrutura inclui a barra lateral do agente e a navegação. É para desenvolvedores que acrescentam rotas a esses aplicativos React.

Quando usar

  • ✓Quando você está acrescentando uma nova página a um aplicativo Agent-Native.
  • ✓Quando a barra lateral do agente é recarregada toda vez que o usuário muda de página.
  • ✓Quando você precisa escolher entre um layout raiz e uma rota de layout sem caminho.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-side-routing/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Pode acrescentar uma nova página de relatórios ao meu aplicativo sem que a barra lateral do agente recarregue ao navegar até ela?”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente monta a estrutura compartilhada uma única vez, acima da área de páginas, e usa uma rota de layout sem caminho quando algumas páginas são públicas e outras são privadas.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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
Perguntas frequentes

Por que a barra lateral do agente recarrega?

Geralmente acontece quando cada página envolve a si mesma no seu próprio layout, então a estrutura é remontada na navegação.

O que é uma rota de layout sem caminho?

É uma rota pai que adiciona um layout sem acrescentar um trecho ao endereço da web.

Qual framework é usado?

A skill diz que os aplicativos usam React Router como aplicações de página única.

Detalhes

Descrição original do 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

Popularidade

Estrelas no GitHub
7,6 mil
Posição no ranking
#13146
Licença
MIT
Atualizada em
02/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas