1.0.0 • Published 6 years ago

react-route-extended v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

react-route-extended

Authenticated Route support for React Router 4

Why this is useful?

This simple component allows you to simplify creating routes in react which require authentication, by simply passing a boolean value as prop on your route component.

  • Lightweight (less than 1kb)
  • Supports both public and private routes - no need to manage multiple components
  • Redirect to a custom route when authentication fails or fallback to the bundled route handler
  • Wraps around the react-router-dom API so supports all standard <Route /> features

Installation

$ npm install --save react-route-extended
# or
$ yarn add react-route-extended

Usage

Import Route into your component

import Route from 'react-route-extended'

Create a public route

<Route path="/public" component={HomePage} />

Create a private route

<Route auth={isUserAuthenticated} path="/private" component={PrivatePage} />

Create a private route w/ a custom redirect

<Route auth={isUserAuthenticated} path="/private" component={PrivatePage} redirect={'/nope'} />

1.0.0

6 years ago

0.0.0-alpha002

6 years ago

0.0.0-alpha001

6 years ago

0.0.0

6 years ago