npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@meng-xi/uni-router

v2.0.0

Published

为 uni-app 提供类似 vue-router 风格的路由管理系统

Readme

中文 | English

license npm npm

特性

  • vue-router 风格 API - push / replace / relaunch / back
  • 路由守卫 - beforeEach / beforeResolve / afterEach / beforeEnterguardRoute 冷启动补执行
  • 命名路由 & 路由元信息 - 通过 name 导航,meta 携带自定义数据
  • 插件架构 - ParamsPlugin / AnimationPlugin / ChannelPlugin / InterceptorPlugin 按需注册
  • TypeScript 类型提示 - 路由名称和路径自动补全与类型检查
  • 页面间通信 - useUniEventChannel 内置通信管理器,所有导航方式支持 eventChannel
  • 声明式导航 - RouterLink + TabBar / TabBarItem 组件,支持 SCSS 主题定制
  • 页面参数传递 - params 传递复杂数据不暴露 URL,back() 后自动保留
  • 查询参数增强 - queryInt() / queryNumber() / queryBool()
  • 导航动画 - push / replace / back 支持动画参数,仅 App 端
  • 路由状态自动同步 - app.use(router) 注入全局 Mixin 自动 syncRoute()
  • 错误处理 - RouterError / NavigationFailure / UniApiError,支持 instanceof 精准判断
  • 组合式 API - useRouter() / useRoute() / usePageChannel()

安装

pnpm add @meng-xi/uni-router

配合 @meng-xi/vite-pluginpages.json 自动生成路由配置和类型声明:

pnpm add @meng-xi/vite-plugin -D

快速开始

1. 创建路由器

// src/main.ts
import { createSSRApp } from 'vue'
import { createRouter, ParamsPlugin, ChannelPlugin, InterceptorPlugin } from '@meng-xi/uni-router'
import routes from './router.config'
import App from './App.vue'

const router = createRouter({
	routes,
	plugins: [ParamsPlugin, ChannelPlugin, InterceptorPlugin], // 按需注册插件
	interceptUniApi: true // 需要 InterceptorPlugin,拦截原生 API 确保守卫生效
})

export function createApp() {
	const app = createSSRApp(App)
	app.use(router) // 注入全局 mixin,onShow 时自动 syncRoute()
	return { app }
}

2. 路由导航

const router = useRouter()

await router.push({ path: '/pages/about/about', query: { id: '1' } })
await router.push({ name: 'about' })
await router.push({ path: '/pages/detail/detail', params: { info: { name: 'Tom' } } })
await router.back()

3. 路由守卫

router.beforeEach((to, from, next) => {
	if (to.meta.requireAuth && !isLoggedIn()) {
		next({ name: 'login' }, { mode: 'replace' })
	} else {
		next()
	}
})

4. 组件

<!-- RouterLink:声明式导航 -->
<RouterLink :to="{ name: 'about' }">关于</RouterLink>

<!-- TabBar / TabBarItem:自定义底部导航 -->
<TabBar>
  <TabBarItem to="/pages/index/index" icon-path="/static/home.png" text="首页" />
  <TabBarItem to="/pages/about/about" icon-path="/static/user.png" text="我的" dot />
</TabBar>

文档

📖 https://mengxi-studio.github.io/uni-router/v1/

License

MIT