@funstack/router

中文文档
1.6.0发布于 2026/10/22MITTypeScriptES Module构建来源已验证近 30 天下载 2197

A modern React router based on the Navigation API

原始使用文档
文档目录9 节
  1. Features
  2. Installation
  3. AI Coding Agent Support
  4. Development
  5. Packages
  6. Quick Start
  7. Documentation
  8. Path Patterns
  9. License

FUNSTACK Router

FUNSTACK Router

A modern React router built on the Navigation API.

Features

  • :white_check_mark: Navigation API based - Uses the modern Navigation API (supported by Chrome, Firefox and Safari 26.2+)
    • Native <a> tags just work - No special <Link> component needed; use standard HTML links
  • :white_check_mark: Async React compatible - navigations are transitions by default
  • :white_check_mark: RSC Compatible - Designed to work also with React Server Components

Installation

npm install @funstack/router

AI Coding Agent Support

@funstack/router ships with an Agent skill that gives your coding assistant (Claude Code, Cursor, GitHub Copilot, etc.) knowledge about the router's API and best practices. Run:

npx -p @funstack/router funstack-router-skill-installer
# or
pnpm dlx --package @funstack/router funstack-router-skill-installer
# or
yarn dlx -p @funstack/router funstack-router-skill-installer

The installer will guide you through setting up the skill for your preferred AI agent. Alternatively, if you prefer npx skills:

npx skills add uhyo/funstack-router

Development

This is a pnpm monorepo. To set up the development environment:

# Install dependencies
pnpm install

# Build the router package
pnpm build

# Run the example app
pnpm --filter funstack-router-example dev

# Run tests
pnpm test

Packages

  • packages/router - The main @funstack/router library
  • packages/example - Example application
  • packages/docs - Documentation site

Quick Start

import { Router, Outlet, route } from "@funstack/router";
import type { RouteDefinition, RouteComponentProps } from "@funstack/router";

function Layout() {
  return (
    <div>
      <nav>
        {/* Native <a> tags work for client-side navigation */}
        <a href="/">Home</a>
        <a href="/users">Users</a>
      </nav>
      <Outlet />
    </div>
  );
}

function Home() {
  return <h1>Home</h1>;
}

function Users() {
  return <h1>Users</h1>;
}

function UserDetail({ params }: RouteComponentProps<{ id: string }>) {
  return <h1>User {params.id}</h1>;
}

const routes: RouteDefinition[] = [
  route({
    path: "/",
    component: Layout,
    children: [
      route({ path: "", component: Home }),
      route({ path: "users", component: Users }),
      route({ path: "users/:id", component: UserDetail }),
    ],
  }),
];

function App() {
  return <Router routes={routes} />;
}

Documentation

Full documentation is available at router.funstack.work, including:

  • API Reference - Components, hooks, utilities, and types
  • Learn - Guides on nested routes, type safety, SSR, RSC, and more

Path Patterns

FUNSTACK Router uses the URLPattern API for path matching.

PatternExampleMatches
/users/usersExact match
/users/:id/users/123Named parameter
/docs/:section?/docs, /docs/introOptional parameter
/files/:path+/files/a/bRepeated parameter (1 or more)
/users/:id(\d+)/users/123Parameter with regex
/files/*/files/a/b/cWildcard

These patterns also work on parent routes: the matched portion is consumed as a prefix and the rest of the pathname is matched against child routes.

License

MIT

版本与发布记录

@funstack/router 共发布 25 个版本,首次发布于 2025/12/10;过去 12 个月发布了 25 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.6.0latest2026/10/2224 天前
1.5.02026/10/081 个月前
1.4.02026/08/272 个月前
1.3.02026/08/212 个月前
1.2.02026/07/193 个月前
1.1.12026/05/205 个月前

其他发布通道:alpha → 0.0.7-alpha.0。

关于 @funstack/router 的常见问题

@funstack/router 是什么?

A modern React router based on the Navigation API

如何安装 @funstack/router?

在项目目录运行 npm install @funstack/router,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.2.0)、react-dom(^19.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 funstack-router-skill-installer,可以用 npx funstack-router-skill-installer 直接运行。

@funstack/router 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@funstack/router 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@funstack/router 可以商用吗?

@funstack/router 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@funstack/router 的下载量有多少?

根据 npm 官方下载统计,@funstack/router 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,197 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@funstack/router 还在维护吗?

最新版本 1.6.0 发布于 2026/10/22(24 天前);至今共发布 25 个版本,其中过去 12 个月发布了 25 个;首次发布于 2025/12/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。