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

jfreact-router

v1.0.7

Published

**Summary**

Downloads

15

Readme

jfreact-router

Summary

This library is mainly to solve the problem of on-demand loading of react routing, lazy loading routing, caching routing, making home page loading more efficient, and it will be very convenient to use.

Install

npm i jfreact-router --save

How to use

  1. Custom your router config file router/index.js:
import { creteJfRouter } from 'freact-router'

const data = [
  {
    path: '/',
    name: 'Home',
    component: () => import(/* webpackChunkName: "home" */ '@/views/home')
    // component: Home
  },
  {
    path: '/login/:id/:name',
    name: 'Login',
    component: () => import(/* webpackChunkName: "login" */ '@/views/login')
    // component: Login
  },
  {
    path: '/private-room/:id',
    name: 'PrivateRoom',
    component: () =>
      import(/* webpackChunkName: "private_room" */ '@/views/room/private-room')
  },
  {
    path: '/group-room/:id/:name',
    name: 'GroupRoom',
    component: () =>
      import(/* webpackChunkName: "group_room" */ '@/views/room/group-room')
  },
  {
    path: '/my',
    name: 'My',
    component: () => import(/* webpackChunkName: "my" */ '@/views/my'),
    children: [
      {
        path: '/personal',
        name: 'Personal',
        component: () =>
          import(/* webpackChunkName: "personal" */ '@/views/my/personal'),
        children: [
          {
            path: '/setting',
            name: 'Setting',
            component: () =>
              import(
                /* webpackChunkName: "setting" */ '@/views/my/personal/setting'
              )
          }
        ]
      }
    ]
  }
]

export default creteJfRouter(data)
  1. Init router in index.js file:
import { initJfRouter } from 'jfreact-router'
initJfRouter() // 初始化
  1. Then, add code to your App.js file:
import React from 'react'
import './index.scss'
import routers from '@/routers'
import { dynamicModuleLoading, onRouter } from 'jfreact-router'
import { HashRouter, Route, Switch } from 'react-router-dom'
class App extends React.component {
  constructor(props) {
    super(props)
    this.routers = []
    this.currentRoute = null // 当前路由
    this.CurrentPage = null // 当前页面
    this.dynamicModuleLoading = dynamicModuleLoading.bind(this)
  }

  UNSAFE_componentWillMount() {
    this.dynamicModuleLoading(routers).then(({ currentRoute, CurrentPage }) => {
      this.CurrentPage = CurrentPage
      this.currentRoute = currentRoute
      this.forceUpdate()
    })
    // url地址变化后动态加载模块
    onRouter(() => {
      this.dynamicModuleLoading(routers).then(
        ({ currentRoute, CurrentPage }) => {
          this.CurrentPage = CurrentPage
          this.currentRoute = currentRoute
          this.forceUpdate()
        }
      )
    })
  }

  render() {
    const { CurrentPage, currentRoute } = this
    return (
      <div className="app">
        <HashRouter>
          <Switch>
            {CurrentPage && currentRoute && currentRoute?.path ? (
              <Route
                exact
                path={currentRoute?.path}
                render={() => {
                  return <CurrentPage />
                }}
              />
            ) : null}
          </Switch>
        </HashRouter>
      </div>
    )
  }
}

export default App

4.Added global routing parameter access, you can add code in base-component:

// 获取路由参数
  $query() {
    return window.$jfrouter?.query || {}
  }

Modules

  • creteJfRouter Flattened your router data structure
  • dynamicModuleLoading Dynamic loading your business module
  • Dispatcher Event bus
  • initJfRouter Start watching url address change
  • onRouter Watching url change callback