跳到正文
Skillpedia
网站与界面(前端)7.6k · #13168

native-navigation

它能做什么

这项技能规定在 Agent-Native 应用中,何时应使用真正的链接进行导航,而不是用代码移动页面的按钮。它能保证 Cmd 点击、中键点击和键盘操作依然有效。适合在界面中构建导航的开发者。

适用场景

  • ✓当你要添加一个应当打开应用中另一个页面的按钮或卡片的时候。
  • ✓当某个导航控件对 Cmd 点击或中键点击没有反应的时候。
  • ✓当你需要在内部链接和外部链接之间做选择的时候。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/native-navigation/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请修改项目卡片,让它们打开项目页面,并且仍然支持 Cmd 点击。”

每周 5 个新技能,1 分钟读完。

工作原理

开发者对应用内的页面使用路由器链接,对外部或需要新标签页打开的页面使用普通链接,并在需要的地方把按钮包裹在链接中。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Native Navigation

Rule

Pure navigation must render a real React Router <Link> for same-SPA routes, a native <a href> for external/public or explicit new-tab destinations, or a shadcn Button asChild wrapper around one. Do not use a button whose only job is to call navigate(), window.open(), or window.location.

Why

Browser modifier-click, middle-click, keyboard activation, accessibility, and normal client-side routing come from real links. Imperative JavaScript navigation hides the destination and blocks those browser semantics.

How

import { Link } from "react-router";

<Link to={`/items/${item.id}`}>...</Link>

<Button asChild>
  <Link to="/settings">Settings</Link>
</Button>

<a href={previewUrl} target="_blank" rel="noopener noreferrer">
  Preview
</a>
  • Use Link for same-SPA internal routes.
  • Use <a> when the URL is external, crosses an app/public boundary, is an auth or sign-in destination, or intentionally opens in a new tab.
  • Preserve query strings and hashes in to or href.
  • For cards with nested actions, link only the non-interactive card region or use a transparent Link overlay; never nest links or buttons.
  • If selection mode changes click behavior, prevent default only for an unmodified primary click and preserve modified clicks.

Keep imperative navigation for post-mutation redirects, OAuth and popup flows, downloads, media/blob URLs, playback, keyboard shortcuts, and stateful tabs.

Review

Search for onClick={() => navigate, window.open, window.location, onAuxClick, and buttons whose only purpose is routing. For each candidate, confirm whether it is pure navigation or a stateful workflow before changing it.

Verify the rendered DOM exposes an href, then test normal click, Cmd/Ctrl-click, middle-click, keyboard Enter, and nested controls where applicable. Run oxfmt and focused app tests or typechecks for the touched package.

Related Skills

  • client-side-routing
  • frontend-design
  • shadcn-ui
常见问题

为什么不用按钮进行导航?

按钮会隐藏目标地址,并阻断 Cmd 点击和中键点击等浏览器行为。

什么时候仍应使用代码导航?

技能说明,它适用于更新后的重定向,以及登录和弹窗流程。

卡片内部有按钮的情况怎么办?

技能说明只把卡片中非交互的部分设为链接,并且绝不嵌套链接或按钮。

详情

作者的原始描述

Use when adding or reviewing UI navigation so internal routes preserve normal SPA behavior plus Cmd/Ctrl-click and middle-click new-tab semantics.

repo: BuilderIO/agent-native

热度

GitHub 星标
7.6k
排名
#13168
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能