# react-router-guard

> React Router Guard

Latest version **2.3.1** (published 2022-04-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-router-guard
pnpm add react-router-guard
yarn add react-router-guard
bun add react-router-guard
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.1 |
| Published | 2022-04-11 |
| First published | 2018-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 3 |
| Unpacked size | 977.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | laptransang |
| Maintainers | laptransang |
| Keywords | react, router, guard, react authentication router, react router auth, react router code splitting, react router lazy |

## Links

- npm: https://www.npmjs.com/package/react-router-guard
- Repository: https://github.com/laptransang/react-router-guard
- Homepage: https://github.com/laptransang/react-router-guard#readme
- Issues: https://github.com/laptransang/react-router-guard/issues
- npm.io page: https://npm.io/package/react-router-guard

## Dependencies (3)

- [history](https://npm.io/package/history.md) 4.7.2
- [react-loadable](https://npm.io/package/react-loadable.md) ^5.5.0
- [react-router-dom](https://npm.io/package/react-router-dom.md) ^4.3.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.3.1 (latest) — 2022-04-11
- 2.3.0 — 2019-12-20
- 2.2.0 — 2019-10-11
- 2.1.0 — 2019-08-12
- 2.0.2 — 2019-05-06
- 2.0.1 — 2019-05-03
- 2.0.0 — 2019-04-18
- 1.0.4 — 2018-12-21
- 1.0.3 — 2018-12-21
- 1.0.2 — 2018-12-21
- 1.0.1 — 2018-12-09
- 1.0.0 — 2018-12-09

## README

<h3 align="center">
  React Router Guard
</h3>

[![NPM](https://img.shields.io/npm/v/react-router-guard.svg)](https://www.npmjs.com/package/react-router-guard) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install
**npm**

```bash
npm install --save react-router-guard
```
**yarn**
```bash
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](https://codesandbox.io/s/5wr9ow6xlk) and [docs](/docs/guides/Content.md)

## Usage
```javascript
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
<table class="table table-bordered table-striped">
    <thead>
    <tr>
        <th style="width: 100px;">name</th>
        <th style="width: 50px;">type</th>
        <th>description</th>
    </tr>
    </thead>
    <tbody>
      <tr>
          <td>config</td>
          <td>RouterGuardConfigProps[]</td>
          <td>The config for render all route</td>
      </tr>
      <tr>
          <td>history</td>
          <td>createBrowserHistory()</td>
          <td>To use custom history</td>
      </tr>
    </tbody>
</table>

## Docs
[Migrating from 1.x to 2.x](/docs/guides/Migrating.md)

[Docs](/docs/guides/Content.md)

## Screenshot & Demo

[Demo](https://codesandbox.io/s/5wr9ow6xlk)

<img width="500" src="https://drive.google.com/uc?id=1biXJPFwo8hzA26_QQ5KgAZFf1ZoMrCnT" />

React Router Guard

## License

MIT © [TSL](https://github.com/tsl)
=======

---
_Source: https://npm.io/package/react-router-guard · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
