Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-router-guard

laptransang527MIT2.3.1TypeScript support: included

React Router Guard

react, router, guard, react authentication router, react router auth, react router code splitting, react router lazy

readme

React Router Guard

NPM JavaScript Style Guide

Install

npm

npm install --save react-router-guard

yarn

yarn add react-router-guard

Introduction

React Router Guard is a router structure base on react-router-dom, when you install react-router-guard you don't need to install (react-router-dom, history, react-loadable) because it uses these packages as dependencies, it gives you some cool feature like router-config, code splitting, router authentication support, dynamic redirect for more information please read the demo and docs

Usage

import React from 'react';
import ReactDOM from 'react-dom';
/*
Because we don't need to install react-router-dom so you can use Link or NavLink from 'react-router-guard'
import { RouterGuard, BrowserRouter, Link, NavLink, Redirect, Route, Router, Switch, history, withRouter, Loadable } from 'react-router-guard';
*/
import { RouterGuard } from 'react-router-guard';
import config from './config';

function App() {
  return (
    <div className="App">
      <RouterGuard config={config} />
    </div>
  );
}

const rootElement = document.getElementById('root'); // eslint-disable-line
ReactDOM.render(<App />, rootElement);

API

name type description
config RouterGuardConfigProps[] The config for render all route
history createBrowserHistory() To use custom history

Docs

Migrating from 1.x to 2.x

Docs

Screenshot & Demo

Demo

React Router Guard

License

MIT © TSL