1.0.4 • Published 6 years ago

privateroute v1.0.4

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

PrivateRoute

npm link

Restrict React Components with PrivateRoute

Installing

npm install privateroute

Usage

PrivateRoute will accept a request to the specified component represented by the specified path if the "key" variable in sessionStorage is set. Otherwise, it will redirect to the "/" page.

import PrivateRoute from 'privateroute';

// User is logged in, I will set the key as the userId
sessionStorage.setItem('key', '123')

// Will redirect to home because sesssionStorage has "key" set
<PrivateRoute path="/home" component={YOUR_REACT_COMPONENT} />
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago