slex-router

$ npm install slex-router

Usage no npm install needed!

<script type="module">
  import slexRouter from 'https://cdn.skypack.dev/slex-router';
</script>

README

CircleCI

Slex Router

$ npm install slex-router

slex-router is a simple client side router which exposes an rxjs stream.

Example Usage

import slexRouter from 'slex-router'

const routes = {
  '/': {
    name: 'home',
    ...anything
  },
  '/item/:id': {
    name: 'itemDetails',
    ...anything
  },
  '/item/:id/child/:childId': {
    name: 'itemDetailsDeep',
    ...anything
  },
  '/*params': {
    name: 'wildcardRoute',
    ...anything
  }
  'default': {
    name: 'defaultRoute',
    ...anything
  }
}

const router = slexRouter
  .createStream(routes)

const subscription = router.subscribe(nextRoute => {
  const { route, routeState } = nextRoute
  const { name, ...anything } = route
  const { id, childId } = routeState
})

subscription.dispose()