Zum Inhalt springen
Skillpedia
Websites & UI (Frontend)7.6k · #13146

client-side-routing

Was er macht

Dieser Skill erklärt, wie man Seiten zu einer Agent-Native-App hinzufügt, während die gemeinsame Hülle eingebunden bleibt. Die Hülle enthält die Agenten-Seitenleiste und die Navigation. Er richtet sich an Entwickler, die Routen zu diesen React-Apps hinzufügen.

Wann du ihn nutzt

  • ✓Wenn du einer Agent-Native-App eine neue Seite hinzufügst.
  • ✓Wenn die Agenten-Seitenleiste bei jedem Seitenwechsel neu lädt.
  • ✓Wenn du zwischen einem Wurzel-Layout und einer Layout-Route ohne Pfad wählen musst.

Link zum Skill

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

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-side-routing/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Kannst du meiner App eine neue Berichtsseite hinzufügen, ohne dass die Agenten-Seitenleiste neu lädt, wenn ich dorthin navigiere?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Agent bindet die gemeinsame Hülle einmal über dem Seiten-Ausgabebereich ein. Sind manche Seiten öffentlich und andere privat, nutzt er eine Layout-Route ohne Pfad.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen

Warum lädt die Agenten-Seitenleiste neu?

Das passiert meist, wenn sich jede Seite in ihr eigenes Layout hüllt, sodass die Hülle beim Navigieren neu eingebunden wird.

Was ist eine Layout-Route ohne Pfad?

Sie ist eine übergeordnete Route, die ein Layout hinzufügt, ohne einen Teil zur Web-Adresse beizutragen.

Welches Framework wird genutzt?

Der Skill sagt, die Apps nutzen React Router als Single-Page-Apps.

Details

Originalbeschreibung des Autors

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

Beliebtheit

GitHub-Sterne
7.6k
Platz im Ranking
#13146
Lizenz
MIT
Aktualisiert
2.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills