1.7.3 • Published 4 years ago
react-auth0-helper v1.7.3
React Auth0 Authentication helper
with @auth0/auth0-spa-js
Note :-
make sure you have the enviroment variables listed below in your .env file or in a config file. If you have the configs in your .env you dont need to pass them in your provider.
- REACT_APP_AUTH0_CLIENT_ID,
- REACT_APP_AUTH0_DOMAIN,
- REACT_APP_AUTH0_REDIRECT_URI,
defaults:
available props
auth { isAuthenticated: boolean; user: { token: string; userId: string; companyId: string; }; loading: boolean; handleRedirectCallback: () => void; getTokenSilently: () => void; getIdTokenClaims: () => void; loginWithRedirect: () => void; logout: () => void; }
index
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { Auth0Provider } from "react-auth0-helper";
import config from "./auth_config.json";
// A function that routes the user to the right place
// after login
const onSuccessfulLogin = (user) => {
console.info(user)
};
const auth0config = {
client_id: clientEnv.AUTH0_CLIENT_ID,
domain: clientEnv.AUTH0_DOMAIN,
redirectUri: clientEnv.AUTH0_DOMAIN,
}
ReactDOM.render(
<Auth0Provider
onSuccessfulLogin={onSuccessfulLogin}>
config={auth0config}
forceAuth={false} // default is true, change to false if users should access even without loging in
<App />
</Auth0Provider>,
document.getElementById("root")
);
serviceWorker.unregister();
App
import React from "react";
import NavBar from "./components/NavBar";
import { withAuth0 } from "./react-auth0-helper";
class App extends React.PureComponent () {
const { loading } = this.props;
if (loading) {
return (
<div>Loading...</div>
);
}
return (
<div className="App">
<header>
<NavBar />
</header>
</div>
);
}
export default withAuth0()(App)
1.7.3
4 years ago
1.7.2
4 years ago
1.7.1
4 years ago
1.6.0
4 years ago
1.5.0
4 years ago
1.4.9
4 years ago
1.4.8
4 years ago
1.4.7
4 years ago
1.4.6
4 years ago
1.4.5
4 years ago
1.4.4
4 years ago
1.4.3
4 years ago
1.4.1
4 years ago
1.3.7
4 years ago
1.4.0
4 years ago
1.3.6
4 years ago
1.3.5
4 years ago
1.3.4
4 years ago
1.2.4
4 years ago
1.1.4
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
5 years ago
1.0.1
5 years ago