@vseth/auth
v2.0.0-alpha.6
Published
NPM Package for Auth Helper
Downloads
243
Readme
vseth-auth
NPM Package for Auth Helper
useAuth
React Hook. TODO docs, look at the src
Authprovider
The Authprovider provides the context for the hook, it need to be at the root or close to it and there should only be one.
Protected Route
A wrapped react-router-dom route component that checks wheter the user has sufficient priviledge to access this route and otherwise displays an error
Usage example
const App: React.FunctionComponent<any> = () => {
return (
<AuthProvider>
<Router>
<Switch>
<Route path="/">
<p>Unprotected</p>
</Route>
<ProtectedRoute path="/protected">
<p>Protected</p>
</ProtectedRoute>
</Switch>
</Router>
</AuthProvider>
);
};