0.8.0 • Published 2 years ago

@routo/core v0.8.0

Weekly downloads
15
License
MIT
Repository
github
Last release
2 years ago

routo

@routo/core

npm npm bundle size coverage license

Simple framework-agnostic router

Install

yarn add @routo/core

Usage

import { createRouter } from '@routo/core';

const HOME = 'router/HOME';
const POST = 'router/POST';

const routes = [
  {
    id: HOME,
    path: '/',
  },
  {
    id: POST,
    path: '/posts/:id',
  },
];

const router = createRouter(routes);

const unsubscribe = router.subscribe((state) => console.log(state.pathname));

router.replace(POST, { params: { id: '42' } });
// /posts/42

unsubscribe();

State

{
  id: 'router/POST',
  pathname: '/posts/42',
  search: '',
  queryParams: {},
  action: 'PUSH',
  params: { id: '42' },
  prev: {
    id: 'router/HOME',
    pathname: '/',
    search: '',
    queryParams: {},
    action: null,
    params: {}
    prev: null,
  }
}

License

MIT © Timofey Dergachev

0.8.0

2 years ago

0.7.0

3 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago