argon-router
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseArgon Router
Argon Router
Use this skill to implement argon-router in React web apps with predictable Effector dataflow and typed paths.
在具有可预测Effector数据流和类型化路径的React Web应用中,使用此skill来实现argon-router。
Workflow
工作流程
- Classify the task:
- : create route map, router, and controls.
setup - : connect router to React views, links, and outlet.
ui - : integrate argon-router with React Navigation in React Native.
native - : track URL query state and sync enter/exit flows.
query - : build derived/protected/virtual routes.
composition - : pick and configure history/query/custom adapter.
adapters - : scope-safe initialization with memory history and
ssr.allSettled - : route activity and router access hooks in React.
hooks - : validate path/router wiring and route lifecycle.
debug
- Load only required references:
- Always start with .
references/core-routing.md - Add for any React integration task.
references/react-web.md - Add for React Native stack/tabs integration.
references/react-native.md - Add when working with route path syntax or parsing/building URLs.
references/paths-dsl.md - Add when query params or filters are involved.
references/query-tracking.md - Add when using auth guards, grouped states, or virtual routes.
references/route-composition.md - Add for
references/adapters-ssr.md/historyAdapter, adapter selection, SSR bootstrap.queryAdapter - Add for
references/react-navigation-apis.md,Link,useRouter,useRouterContext,useIsOpened.useOpenedViews - Add for
references/lazy-layout.mdandcreateLazyRouteView.withLayout - Add for copyable happy-path scaffolds.
references/examples.md - End with before final output.
references/checklist.md
- Resolve source of truth before implementation:
- Prefer and package
../argon-router/packages/*/lib/*.tsexports.lib/index.ts - Use docs as explanatory context and examples.
- If docs and code differ, follow code behavior and note mismatch briefly.
- Build in this order:
- Define route units with explicit paths and params.
- Create router controls and initialize history adapter.
- Create router with known routes, optional base, and explicit pathless mapping () when needed.
{ path, route } - Create React route views and wire +
RouterProvider(addcreateRoutesViewwhen fallback behavior is required).otherwise - Add link/navigation actions via route and
openfirst.Link - Use only for custom interaction surfaces.
useLink - Add dynamic registration () only if runtime extension is required.
router.registerRoute(...) - Add query trackers only when URL query behavior is required.
- Add route composition (,
chainRoute) after baseline routing works.group - Add lazy/layout organization (,
createLazyRouteView) when route tree is stable.withLayout
- Produce output contract:
- Router topology: routes, router, controls, view mapping.
- Wiring snippets for navigation and query flows.
- Notes for params/path DSL used by each route.
- Notes on adapter/SSR decisions when relevant.
- Validation checklist with expected lifecycle behavior.
- 对任务进行分类:
- :创建路由映射、路由器和控制器。
setup - :将路由器连接到React视图、链接和Outlet。
ui - :在React Native中集成argon-router与React Navigation。
native - :跟踪URL查询状态并同步进入/退出流程。
query - :构建派生/受保护/虚拟路由。
composition - :选择并配置history/query/自定义适配器。
adapters - :使用内存历史记录和
ssr进行作用域安全的初始化。allSettled - :React中的路由活动和路由器访问钩子。
hooks - :验证路径/路由器连接和路由生命周期。
debug
- 仅加载所需参考资料:
- 始终从开始。
references/core-routing.md - 对于任何React集成任务,添加。
references/react-web.md - 对于React Native栈/标签页集成,添加。
references/react-native.md - 处理路由路径语法或解析/构建URL时,添加。
references/paths-dsl.md - 涉及查询参数或过滤器时,添加。
references/query-tracking.md - 使用身份验证守卫、分组状态或虚拟路由时,添加。
references/route-composition.md - 处理/
historyAdapter、适配器选择、SSR引导时,添加queryAdapter。references/adapters-ssr.md - 处理、
Link、useRouter、useRouterContext、useIsOpened时,添加useOpenedViews。references/react-navigation-apis.md - 处理和
createLazyRouteView时,添加withLayout。references/lazy-layout.md - 如需可复制的最佳实践脚手架,添加。
references/examples.md - 最终输出前,添加。
references/checklist.md
- 实现前确定事实来源:
- 优先使用和包的
../argon-router/packages/*/lib/*.ts导出内容。lib/index.ts - 将文档用作解释性上下文和示例。
- 如果文档与代码存在差异,遵循代码行为并简要说明不匹配之处。
- 按以下顺序构建:
- 定义具有明确路径和参数的路由单元。
- 创建路由器控制器并初始化history适配器。
- 使用已知路由、可选基础路径创建路由器,必要时使用明确的无路径映射()。
{ path, route } - 创建React路由视图并连接+
RouterProvider(需要回退行为时添加createRoutesView)。otherwise - 首先通过路由和
open添加链接/导航操作。Link - 仅在自定义交互界面中使用。
useLink - 仅在需要运行时扩展时添加动态注册()。
router.registerRoute(...) - 仅在需要URL查询行为时添加查询跟踪器。
- 在基础路由正常工作后,添加路由组合(、
chainRoute)。group - 路由树稳定后,添加懒加载/布局组织(、
createLazyRouteView)。withLayout
- 生成输出约定:
- 路由器拓扑:路由、路由器、控制器、视图映射。
- 用于导航和查询流程的连接代码片段。
- 每个路由使用的参数/路径DSL说明。
- 相关的适配器/SSR决策说明。
- 包含预期生命周期行为的验证清单。
Defaults
默认设置
- Target React web only ().
@argon-router/react - Switch to React Native patterns only when task explicitly targets mobile/native stack.
- Use happy-path integration patterns.
- Keep route graph explicit and small before adding composition.
- Prefer declarative Effector links (,
sample) over imperative glue code.attach - Prefer over
Linkunless custom interaction requires manual handlers.useLink
- 仅针对React Web()。
@argon-router/react - 仅当任务明确针对移动/原生栈时,才切换到React Native模式。
- 使用最佳实践集成模式。
- 在添加组合之前,保持路由图明确且简洁。
- 优先使用声明式Effector链接(、
sample)而非命令式粘合代码。attach - 除非自定义交互需要手动处理程序,否则优先使用而非
Link。useLink
Guardrails
注意事项
- Initialize controls with before expecting route activation from URL changes.
setHistory - Pass router adapters to (
setHistoryorhistoryAdapter(...)), not raw history objects.queryAdapter(...) - Ensure every route used by is registered in
useLink.createRouter({ routes }) - Keep route paths deterministic; avoid ambiguous wildcard-heavy patterns unless required.
- Model query state through , not ad-hoc parsing in components.
trackQuery - Keep view rendering centralized in and
createRoutesViewcomposition.Outlet - Add when no-match fallback is part of requirements.
createRoutesView({ otherwise }) - Use for pathname routing and
historyAdapterfor secondary/modal/tab routing.queryAdapter - For SSR/testing, initialize router in scope with .
allSettled(router.setHistory, { params: historyAdapter(createMemoryHistory(...)) })
- 在期望URL更改触发路由激活之前,使用初始化控制器。
setHistory - 将路由器适配器传递给(
setHistory或historyAdapter(...)),而非原始history对象。queryAdapter(...) - 确保使用的每个路由都已在
useLink中注册。createRouter({ routes }) - 保持路由路径确定;除非必要,避免使用模糊的、大量通配符的模式。
- 通过建模查询状态,而非在组件中进行临时解析。
trackQuery - 将视图渲染集中在和
createRoutesView组合中。Outlet - 当无匹配回退是需求的一部分时,添加。
createRoutesView({ otherwise }) - 使用进行路径名路由,使用
historyAdapter进行次要/模态/标签页路由。queryAdapter - 对于SSR/测试,在作用域中使用初始化路由器。
allSettled(router.setHistory, { params: historyAdapter(createMemoryHistory(...)) })