# react-auth0-helper

> with @auth0/auth0-spa-js

Latest version **1.7.3** (published 2020-05-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-auth0-helper
pnpm add react-auth0-helper
yarn add react-auth0-helper
bun add react-auth0-helper
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.3 |
| Published | 2020-05-20 |
| First published | 2019-08-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Andrea & Shiundu |
| Maintainers | benshiundu |
| Keywords | auth0-spa-js, auth0, react-auth0-helper, auth0-helper, auth-helper, react |

## Links

- npm: https://www.npmjs.com/package/react-auth0-helper
- Repository: https://github.com/shiundu/react-auth0-helper
- Homepage: https://github.com/shiundu/react-auth0-helper#readme
- Issues: https://github.com/shiundu/react-auth0-helper/issues
- npm.io page: https://npm.io/package/react-auth0-helper

## Dependencies (4)

- [react](https://npm.io/package/react.md) 16.13.1
- [jwt-decode](https://npm.io/package/jwt-decode.md) ^2.2.0
- [typescript](https://npm.io/package/typescript.md) ^3.8.3
- [@auth0/auth0-spa-js](https://npm.io/package/@auth0/auth0-spa-js.md) 1.8.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.7.3 (latest) — 2020-05-20
- 1.7.2 — 2020-05-20
- 1.7.1 — 2020-05-20
- 1.6.0 — 2020-05-18
- 1.5.0 — 2020-05-10
- 1.4.9 — 2020-05-02
- 1.4.8 — 2020-05-02
- 1.4.7 — 2020-05-02
- 1.4.6 — 2020-05-02
- 1.4.5 — 2020-05-02
- 1.4.4 — 2020-05-02
- 1.4.3 — 2020-05-02
- 1.4.1 — 2020-04-30
- 1.4.0 — 2020-04-30
- 1.3.7 — 2020-04-30
- … 9 more at https://npm.io/package/react-auth0-helper/versions

## README

# 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)

(AuthO)[https://auth0.com/docs/quickstart/spa/react/01-login]

---
_Source: https://npm.io/package/react-auth0-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
