router5

Flexible and powerful universal routing solution

Github星跟蹤圖

Router5

npm version
License: MIT
Build Status Join the chat at https://gitter.im/router5/router5 styled with prettier

Official website: router5.js.org

router5 is a framework and view library agnostic router.

  • view / state separation: router5 processes routing instructions and outputs state updates.
  • universal: works client-side and server-side
  • simple: define your routes, start to listen to route changes
  • flexible: you have control over transitions and what happens on transitions
import createRouter from 'router5'
import browserPlugin from 'router5-plugin-browser'

const routes = [
    { name: 'home', path: '/' },
    { name: 'profile', path: '/profile' }
]

const router = createRouter(routes)

router.usePlugin(browserPlugin())

router.start()

With React (new context API)

import React from 'react'
import ReactDOM from 'react-dom'
import { RouteProvider, Route } from 'react-router5'

function App({ route }) {
    if (!route) {
        return null
    }

    if (route.name === 'home') {
        return <h1>Home</h1>
    }

    if (route.name === 'profile') {
        return <h1>Profile</h1>
    }
}

ReactDOM.render(
    <RouteProvider router={router}>
        <Route>{({ route }) => <App route={route} />}</Route>
    </RouteProvider>,
    document.getElementById('root')
)

With observables

Your router instance is compatible with most observable libraries.

import { from } from 'rxjs/observable/from'

from(router).map(({ route }) => {
    /* happy routing */
})

Examples

Docs

主要指標

概覽
名稱與所有者alibaba/ARouter
主編程語言Java
編程語言JavaScript (語言數: 4)
平台
許可證Apache License 2.0
所有者活动
創建於2016-12-14 01:27:49
推送於2023-09-11 06:07:41
最后一次提交2021-06-17 16:33:36
發布數20
最新版本名稱1.5.2 (發布於 2021-06-22 13:15:24)
第一版名稱1.0.1 (發布於 2017-01-04 17:52:12)
用户参与
星數14.5k
關注者數365
派生數2.6k
提交數301
已啟用問題?
問題數909
打開的問題數123
拉請求數79
打開的拉請求數11
關閉的拉請求數64
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?