0.2.4 • Published 8 years ago

@loll/router v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

@loll/router

Library agnostic route handler.

Install

npm i @loll/router --save

Route handling

import createRouter from '@loll/router'

const router = createRouter([
  ['/', () => {
    return 'Hello world!'
  }]
])

router.get('/') // => Hello world!

Routes may also contain route parameters:

import createRouter from '@loll/router'

const router = createRouter([
  ['/posts/:id', ({ id }) => {
    return `This is post ${id}.`
  }]
])

router.get('/posts/router') // => This is post router.

Configure a wildcard route to catch any fall-through:

import createRouter from '@loll/router'

const router = createRouter([
  ['*', () => {
    return '404 - Page not found'
  }]
])

router.get('/some/other/route') // => 404 - Page not found

Updating the URL

Sure:

router.push('/about') // => window.location.pathname === 'about'

MIT

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago