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

@heathenjs/taro-router

v1.1.5

Published

Taro小程序路由库

Readme

@heathenjs/taro-router

Taro小程序路由库

特性

安装

强烈建议与配套的 @heathenjs/taro-router-plugin 一同安装,享受路由自动生成、跳转参数类型校验等能力带来的开发体验

pnpm

pnpm add @heathenjs/taro-router-plugin --save-dev
pnpm add @heathenjs/taro-router

yarn

yarn add @heathenjs/taro-router-plugin --dev
yarn add @heathenjs/taro-router

npm

npm install @heathenjs/taro-router-plugin --save-dev
npm install @heathenjs/taro-router --save

解决了什么问题?

小程序进行路由跳转时,手写的 url 无法确认链接正确性,且对于必须带参数的页面(如详情页)不能很好的进行跳转前约束;

  • 通过约定的目录结构生产路由跳转方法,通过指定的 API 跳转而不是手写 url;
  • 给特定的页面添加 route.config.ts 描述进入该页面时所需参数类型;

页面跳转希望传递自定义对象时无法操作;

  • 跳转 API 支持传入任意类型的参数,在跳转到的页面中通过 useParams 获取该参数;

无法描述“从页面返回时”的场景,例如进入某个页面进行操作并返回后,刷新当前页面这种场景难以实现;

  • 将跳转行为封装为一个 Promise,当从跳转到的页面返回时,这个 Promise 被 resolve;
  • 支持设定当前页面的 BackData,作为上述 Promise 的参数;

路由鉴权写起来相当啰嗦,而且难以和业务代码解耦;

  • 页面的 route.config.ts 支持配置页面的 Ext 参数(例如所需的权限码),生成路由时自动写入到跳转 API 中;
  • 增加路由中间件功能,在跳转时按顺序进入中间件,则可以添加中间件对上述 Ext 参数结合当前用户身份进行权限校验;