AuthOutlet¶
Import¶
Function Signature¶
AuthOutlet({fallbackPath: string}
): React.ReactNode
AuthOutlet provides an easy solution to implement private route solutions using the react-router-dom route system
Parameters¶
Name | Type | Description |
---|---|---|
fallbackPath |
string |
Path to redirect if the user is not authenticated |
Example¶
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>
);
}
Defined in¶
packages/react-router/src/AuthOutlet.tsx
— 🔑 —
React Auth Kit is MIT License code