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

@composy/router-vanilla

v0.0.1

Published

Vanilla JS router adapter - DOM outlet + view system, part of LDesign Router

Readme

@composy/router-vanilla

面向 Vanilla JS 与 @composy/engine-vanilla 的路由适配层,负责把 @composy/router-core 的能力接到 DOM Outlet、视图注册表和引擎服务容器中。

包定位

  • 核心层不放这里:路径匹配、守卫、中间件、history、缓存等框架无关能力仍来自 @composy/router-core
  • 本包负责
    • createVanillaRouterPlugin()
    • OutletManager
    • ViewRegistry
    • helper 访问器
    • composables 风格的快捷 API

安装

pnpm add @composy/router-vanilla @composy/router-core @composy/engine-vanilla

快速开始

import { createVanillaEngine } from '@composy/engine-vanilla'
import { createVanillaRouterPlugin, getRouter } from '@composy/router-vanilla'
import '@composy/router-vanilla/styles/transitions.css'

const engine = createVanillaEngine({
  plugins: [
    createVanillaRouterPlugin({
      mode: 'hash',
      outlet: '#router-outlet',
      routes: [
        { path: '/', component: HomeView },
        {
          path: '/settings',
          component: SettingsLayoutView,
          children: [
            { path: 'profile', component: SettingsProfileView },
            { path: 'security', component: SettingsSecurityView },
          ],
        },
      ],
    }),
  ],
})

await engine.mount('#app')

const router = getRouter(engine)
await router.push({ path: '/about' })

主要能力

createVanillaRouterPlugin()

  • 创建适用于 @composy/engine-vanilla 的路由插件。
  • 自动创建 history、router、view registry 与 outlet manager。
  • 默认启用与 @composy/router-vue/styles/transitions.css 同名的 route-transition-* 切换动画;需要样式时引入 @composy/router-vanilla/styles/transitions.css
  • 安装后会在容器中注册:
    • router
    • routerOutlet
    • viewRegistry

ViewRegistry

  • 管理路由与视图组件的映射关系。
  • 负责嵌套路由视图树的注册与查询;父视图内放置 <div data-router-outlet></div> 后即可渲染子路由。

OutletManager

  • 管理 DOM outlet 的注册和渲染。
  • 支持根级过渡动画和子路由过渡动画,动画 class 协议与 Vue 适配层保持一致。
  • 负责在导航结束后把目标视图渲染到对应 outlet。

Helpers

  • getRouter(engine)
  • getOutlet(engine)
  • getViewRegistry(engine)

Composables 风格 API

  • useRouter()
  • useRoute()
  • navigate()
  • useHead()
  • createAuthGuard()

公开导出

插件

  • createVanillaRouterPlugin
  • VanillaRouterConfig

视图与 Outlet

  • ViewRegistry
  • OutletManager
  • RouteMeta
  • OutletOptions

Helpers 与 Composables

  • getRouter
  • getOutlet
  • getViewRegistry
  • useRouter
  • useRoute
  • navigate
  • useHead
  • createAuthGuard

依赖关系

  • 运行时必需@composy/router-core
  • 运行时可选但推荐@composy/engine-vanilla
  • 如果不通过 engine 使用,就不需要依赖本包的插件与 helper 层。

构建与校验

packages/router/packages/vanilla 目录下:

pnpm build
pnpm type-check
pnpm test

License

MIT © LDesign Team