tanstack-devtools
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTanStack DevTools
TanStack DevTools
Overview
概述
TanStack DevTools provides debugging panels for inspecting Query cache state, Router route trees, and Form field state in React applications. There are two approaches: standalone devtools per library (, ) and the unified TanStack Devtools panel that combines all libraries into a single interface with plugin architecture.
ReactQueryDevtoolsTanStackRouterDevtoolsWhen to use: Setting up devtools for TanStack libraries, debugging query cache behavior, inspecting route matching, monitoring form field state, or combining multiple TanStack devtools into one panel.
When NOT to use: Production debugging (devtools are tree-shaken in production by default), non-React frameworks without adapter support, or custom state management unrelated to TанStack libraries.
TanStack DevTools 提供调试面板,用于检查 React 应用中的 Query 缓存状态、Router 路由树和 Form 字段状态。有两种使用方式:各库独立开发工具(、),以及统一的 TanStack Devtools 面板,它通过插件架构将所有库整合到一个界面中。
ReactQueryDevtoolsTanStackRouterDevtools适用场景:为 TanStack 系列库搭建开发工具、调试查询缓存行为、检查路由匹配情况、监控表单字段状态,或是将多个 TanStack 开发工具整合到单个面板中。
不适用场景:生产环境调试(开发工具默认会在生产环境中被 tree-shaken 移除)、无适配器支持的非 React 框架,或是与 TanStack 库无关的自定义状态管理。
Quick Reference
快速参考
| Pattern | API | Key Points |
|---|---|---|
| Query devtools (floating) | | Auto-connects to nearest QueryClient |
| Query devtools (embedded) | | Embed in custom layout |
| Router devtools (floating) | | Place in root route component |
| Router devtools (embedded) | | Requires |
| Form devtools | | Plugin for unified devtools |
| Unified devtools | | Single panel for all TanStack libraries |
| Vite plugin | | Source injection, enhanced logs, production removal |
| Production devtools | | Opt-in for production environments |
| Lazy loading | | Reduce bundle size in development |
| Open hotkey | | Keyboard shortcut for unified panel |
| 模式 | API | 核心要点 |
|---|---|---|
| 悬浮式 Query 开发工具 | | 自动连接到最近的 QueryClient |
| 嵌入式 Query 开发工具 | | 可嵌入自定义布局 |
| 悬浮式 Router 开发工具 | | 放置在根路由组件中 |
| 嵌入式 Router 开发工具 | | 在 Provider 外部使用时需要传入 |
| Form 开发工具 | | 统一开发工具的插件 |
| 统一开发工具 | | 单个面板整合所有 TanStack 系列库 |
| Vite 插件 | | 源码注入、增强日志、生产环境自动移除 |
| 生产环境开发工具 | | 需手动开启才能在生产环境使用 |
| 懒加载 | | 减少开发环境下的包体积 |
| 打开快捷键 | | 统一面板的键盘快捷键 |
Unified Devtools Config
统一开发工具配置
| Option | Type | Purpose |
|---|---|---|
| | Trigger button location |
| | Panel slide direction |
| | Panel color scheme |
| | Open panel on load |
| | Hide trigger until hover |
| | Toggle panel shortcut |
| | Source inspector shortcut |
| | Only activate with URL parameter |
| 配置项 | 类型 | 用途 |
|---|---|---|
| | 触发按钮的位置 |
| | 面板滑出方向 |
| | 面板配色方案 |
| | 加载时是否默认打开面板 |
| | 触发按钮仅在 hover 时显示 |
| | 面板切换快捷键 |
| | 源码检查器快捷键 |
| | 仅当 URL 带有指定参数时激活 |
Common Mistakes
常见错误
| Mistake | Correct Pattern |
|---|---|
| Importing devtools in production bundle | Standalone devtools auto-tree-shake; use |
Passing | Omit |
Using | |
| Mixing standalone and unified devtools | Choose one approach; both rendering causes duplicate panels |
| Rendering devtools outside QueryClientProvider | Place |
Using | Place in root route component or pass |
| Forgetting Vite plugin for unified devtools | Add |
| Using unified devtools without framework adapter | Install both |
| 错误操作 | 正确做法 |
|---|---|
| 在生产环境包中引入开发工具 | 独立开发工具会自动被 tree-shake;使用 |
在 RouterProvider 内部使用时传入 | 省略 |
用 | |
| 同时使用独立开发工具和统一开发工具 | 选择其中一种方式;同时渲染会导致面板重复 |
| 在 QueryClientProvider 外部渲染开发工具 | 将 |
在路由树外部使用 | 放在根路由组件中,或显式传入 |
| 使用统一开发工具时忘记配置 Vite 插件 | 在 vite 配置中添加 |
| 未安装框架适配器就使用统一开发工具 | 同时安装 |
Delegation
任务委派
- Devtools setup review: Use agent to verify correct placement and configuration
Task - Bundle size analysis: Use agent to check devtools are tree-shaken in production
Explore - Code review: Delegate to agent
code-reviewer
If theskill is available, delegate query-specific debugging patterns to it. Otherwise, recommend:tanstack-querynpx skills add oakoss/agent-skills --skill tanstack-queryIf theskill is available, delegate route debugging patterns to it. Otherwise, recommend:tanstack-routernpx skills add oakoss/agent-skills --skill tanstack-routerIf theskill is available, delegate form state management and validation patterns to it.tanstack-form
- 开发工具配置审核:使用 agent 验证放置位置和配置是否正确
Task - 包体积分析:使用 agent 检查开发工具是否在生产环境中被 tree-shaken 移除
Explore - 代码审核:委派给 agent
code-reviewer
如果skill 可用,将查询相关的调试模式委派给该 skill。 否则,推荐执行:tanstack-querynpx skills add oakoss/agent-skills --skill tanstack-query如果skill 可用,将路由调试模式委派给该 skill。 否则,推荐执行:tanstack-routernpx skills add oakoss/agent-skills --skill tanstack-router如果skill 可用,将表单状态管理和验证模式委派给该 skill。tanstack-form
References
参考资料
- Query devtools setup, modes, and options
- Router devtools setup, route inspection, and options
- Form devtools and unified devtools patterns
- Query 开发工具的配置、模式及可选参数
- Router 开发工具的配置、路由检查及可选参数
- Form 开发工具及统一开发工具使用模式