All Projects → makeflow → boring-router

makeflow / boring-router

Licence: MIT license
A type-safe MobX router with parallel routing support.

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to boring-router

froute
Type safe and flexible router for React
Stars: ✭ 31 (-58.11%)
Mutual labels:  router, react-router
React Router Page Transition
Highly customizable page transition component for your React Router
Stars: ✭ 531 (+617.57%)
Mutual labels:  router, react-router
React Native Simple Router
A community maintained router component for React Native
Stars: ✭ 266 (+259.46%)
Mutual labels:  router, react-router
cra-redux-boilerplate
⚛️🔨create-react-app application with redux and another cool libraries to make your life easier.
Stars: ✭ 15 (-79.73%)
Mutual labels:  router, react-router
React Router Native Stack
A stack navigation component for react-router-native
Stars: ✭ 171 (+131.08%)
Mutual labels:  router, react-router
react-mobx-router5
React components for routing solution using router5 and mobx
Stars: ✭ 58 (-21.62%)
Mutual labels:  router, mobx
Mobx Router
A simple router for MobX + React apps
Stars: ✭ 489 (+560.81%)
Mutual labels:  router, mobx
Alldemo
🍑 2020全栈学习Demo大合集 包含最新 hooks TS 等 还有umi+dva,数据可视化等实战项目 (持续更新中)
Stars: ✭ 189 (+155.41%)
Mutual labels:  react-router, mobx
Redux First History
🎉 Redux First History - Redux history binding support react-router - @reach/router - wouter
Stars: ✭ 163 (+120.27%)
Mutual labels:  router, react-router
React Redux Graphql Apollo Bootstrap Webpack Starter
react js + redux + graphQL + Apollo + react router + hot reload + devTools + bootstrap + webpack starter
Stars: ✭ 127 (+71.62%)
Mutual labels:  router, react-router
smoothr
A custom React router that leverages the Web Animations API and CSS animations.
Stars: ✭ 28 (-62.16%)
Mutual labels:  router, react-router
react-mobx-router
Create React App with React Router 4 and MobX + Internationalization
Stars: ✭ 90 (+21.62%)
Mutual labels:  react-router, mobx
React Book
《React进阶之路》示例代码
Stars: ✭ 249 (+236.49%)
Mutual labels:  react-router, mobx
yarr
A React router library enabling the render-as-you-fetch concurrent UI pattern.
Stars: ✭ 97 (+31.08%)
Mutual labels:  router, react-router
React Cnodejs.org
Material UI version of cnodejs.org, the biggest Node.js Chinese community.
Stars: ✭ 242 (+227.03%)
Mutual labels:  react-router, mobx
React Router Util
Useful components and utilities for working with React Router
Stars: ✭ 320 (+332.43%)
Mutual labels:  router, react-router
React Mobx Ts Antd
A simple empty project build with react、react-router、mobx、antd in typescript.
Stars: ✭ 53 (-28.38%)
Mutual labels:  react-router, mobx
Koa Mobx React Starter
A straightforward starter for Node javascript web projects. Using Koa, MobX and ReactJS (with universal / isomorphic server rendering)
Stars: ✭ 102 (+37.84%)
Mutual labels:  react-router, mobx
React Redux Antdesign Webpack Starter
react + redux + ant design + react-router 4 + webpack 4 starter
Stars: ✭ 44 (-40.54%)
Mutual labels:  router, react-router
React Live Route
📌 An enhanced react-router-v4/5 Route that keeps route alive.
Stars: ✭ 207 (+179.73%)
Mutual labels:  router, react-router

NPM Package Build Status

Boring Router

A type-safe MobX router with parallel routing support.

Introduction

Boring Router is a state-first router with light-weight route components. It manages observable (MobX) route states like route.$matched and route.$params, so the route components as well as your code can react to those states. Boring Router is written in TypeScript and it puts type safety in mind designing the API.

Installation

# Install dependencies if you haven't
yarn add react react-dom mobx mobx-react-lite

# Install Boring Router packages
yarn add boring-router boring-router-react

Usage

import {Router} from 'boring-router';
import {BrowserHistory, Link, Route} from 'boring-router-react';
import {observer} from 'mobx-react-lite';
import React from 'react';
import ReactDOM from 'react-dom';

const history = new BrowserHistory();

const router = new Router(history);

const route = router.$route({
  $children: {
    workbench: true,
    userSettings: true,
    notFound: {
      $match: /.*/,
    },
  },
});

const App = observer(() => {
  return (
    <>
      <ul>
        <li>
          <Link to={route}>Home</Link>
        </li>
        <li>
          <Link to={route.workbench}>Workbench</Link>
        </li>
        <li>
          <Link to={route.userSettings}>User Settings</Link>
        </li>
      </ul>
      <hr />
      <Route exact match={route} component={HomeView} />
      <Route match={route.workbench} component={WorkbenchView} />
      <Route match={route.userSettings} component={UserSettingsView} />
      <Route match={route.notFound} component={NotFoundView} />
    </>
  );
});

ReactDOM.render(<App />, document.getElementById('app'));

Features

  • Schema-based, type-safe route notation.

    You don't need, and it is not recommended to write routes as strings with Boring Router. Route schema can be shared with Node.js backend and this makes route notations type-safe everywhere.

    Unlike most of other schema-based router, how to use the observable route states to render the view is completely under your control: you can use it with the built-in Route component, or simply compose rendering condition with the route states in your own components.

  • Parallel routes that makes different views route-trackable.

    Views like sidebar and overlay can be easily routed with Boring Router parallel routes.

    URL for parallel routes looks like /workbench?_sidebar=/notifications, and additional parallel routes work just like primary route in most cases.

  • Powerful and complete lifecycle hooks.

    Boring Router supports before/will/after x enter/update/leave hooks.

    To support full lifecycle hooks while keeping history navigation behavior right, Boring Router implements its own BrowserHistory with the ability to restore browser history stack according to a given snapshot.

  • Server-side rendering.

    Boring Router by its nature supports SSR. By using life-cycle hooks (usually asynchronous willEnter hook) and route services, we can easily achieve asynchronous content loading.

License

MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].