3.1.3 • Published 13 days ago

@auth-kit/react-router v3.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days ago

This library contains useful functions to manage private routes using react-router or react-router-dom*.

Usage

AuthOutlet

AuthOutlet provides an easy solution using react-router or react-router-dom to manage private-route.

Routes inside the AuthOutlet will stay protected and only properly authenticated users can access the route.

If the user is not authenticated then the user will be redirected to the fallbackPath.

Example

import AuthOutlet from '@auth-kit/react-router/AuthOutlet';

function App() {
 return (
   <Router>
     <Routes>
       <Route element={<AuthOutlet fallbackPath='/login' />}>
         <Route path='/' element={<Users/>} />
         <Route path='/products' element={<Products/>} />
       </Route>
       <Route path='/login' element={<Login/>}/>
     </Routes>
   </Router>
 );
}

RequireAuth

RequireAuth provides a per route base private route solution to implement a private route solution.

Component inside the RequireAuth will stay protected and only properly authenticated users can access the route.

If the user is not authenticated then the user will be redirected to the fallbackPath.

Example

import RequireAuth from '@auth-kit/react-router/RequireAuth';

const RoutesComponent = () => {
 return (
   <BrowserRouter>
     <Routes>
       <Route path={'/'} element={<Home/>}/>
       <Route path={'/login' } element={<Login/>}/>
       <Route path={'/secure'} element={
         <RequireAuth fallbackPath={'/login'}>
           <SecureComponent/>
         </RequireAuth>
       }/>
     </Routes>
   </BrowserRouter>
 )
}

Reference

Reference


3.1.4-alpha.59

13 days ago

3.1.4-alpha.57

14 days ago

3.1.4-alpha.31

1 month ago

3.1.4-alpha.35

1 month ago

3.1.4-alpha.39

1 month ago

3.1.4-alpha.40

1 month ago

3.1.4-alpha.16

1 month ago

3.1.4-alpha.19

1 month ago

3.1.4-alpha.20

1 month ago

3.1.4-alpha.24

1 month ago

3.1.4-alpha.21

1 month ago

3.1.4-alpha.22

1 month ago

3.1.4-alpha.27

1 month ago

3.1.4-alpha.28

1 month ago

3.1.4-alpha.25

1 month ago

3.1.4-alpha.26

1 month ago

3.1.4-alpha.29

1 month ago

3.1.4-alpha.30

1 month ago

3.1.4-alpha.11

2 months ago

3.1.4-alpha.15

2 months ago

3.1.4-alpha.8

2 months ago

3.1.4-alpha.7

2 months ago

3.1.3

2 months ago

3.1.4-alpha.0

2 months ago

3.1.4-alpha.4

2 months ago

3.1.4-alpha.6

2 months ago

3.1.4-alpha.5

2 months ago

3.1.2

3 months ago

3.1.2-alpha.1

3 months ago

3.1.2-alpha.2

3 months ago

3.1.2-alpha.3

3 months ago

3.1.2-alpha.4

3 months ago

3.1.1

3 months ago

3.1.0

3 months ago

3.0.2-alpha.19

4 months ago

3.0.2-alpha.13

4 months ago

3.0.2-alpha.14

4 months ago

3.0.2-alpha.11

4 months ago

3.0.2-alpha.12

4 months ago

3.0.2-alpha.10

4 months ago

3.0.2-alpha.16

4 months ago

3.0.2-alpha.4

4 months ago

3.0.2-alpha.8

4 months ago

3.0.2-alpha.1

4 months ago

3.0.2-alpha.2

4 months ago

3.0.2-alpha.3

4 months ago

3.0.2-alpha.0

4 months ago

3.0.1

4 months ago

3.0.0

4 months ago

3.0.0-alpha.46

4 months ago

3.0.0-alpha.43

6 months ago

3.0.0-alpha.45

6 months ago

3.0.0-alpha.44

6 months ago

3.0.0-alpha.36

6 months ago

3.0.0-alpha.35

6 months ago

3.0.0-alpha.41

6 months ago

3.0.0-alpha.17

7 months ago

3.0.0-alpha.2

7 months ago

1.0.0

9 months ago