# cfs-expo-auth0

> Library for Auth0 React context for Expo in Create Full Stack.

Latest version **0.2.0** (published 2020-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install cfs-expo-auth0
pnpm add cfs-expo-auth0
yarn add cfs-expo-auth0
bun add cfs-expo-auth0
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-10-09 |
| First published | 2020-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 97 |
| Maintainers | tiagob |

## Links

- npm: https://www.npmjs.com/package/cfs-expo-auth0
- Repository: https://github.com/tiagob/create-full-stack
- Homepage: https://github.com/tiagob/create-full-stack#readme
- Issues: https://github.com/tiagob/create-full-stack/issues
- npm.io page: https://npm.io/package/cfs-expo-auth0

## Recent versions

- 0.2.0 (latest) — 2020-10-09
- 0.1.7 — 2020-10-04
- 0.1.6 — 2020-09-27
- 0.1.5 — 2020-09-23
- 0.1.4 — 2020-09-18
- 0.1.3 — 2020-09-18
- 0.1.2 — 2020-09-11
- 0.1.1 — 2020-09-10
- 0.1.0 — 2020-09-08

## README

# cfs-expo-auth0

This package includes the shareable Expo Auth0 library used by [Create Full Stack](https://github.com/tiagob/create-full-stack).<br>
Please refer to its documentation:

- [Getting Started](https://create-full-stack.com/docs) – How to create a new full stack.
- [User Guide](https://create-full-stack.com) – How to develop apps bootstrapped with Create Full Stack.

## Usage in Create Full Stack Projects

The easiest way to use this is with [Create Full Stack](https://github.com/tiagob/create-full-stack), which includes it by default.

**You don’t need to configure it separately in Create Full Stack projects.**

## Usage Outside of Create Full Stack

### Installation

Using [yarn](https://yarnpkg.com/)

```bash
yarn add cfs-expo-auth0
```

Using [npm](https://www.npmjs.com/)

```bash
npm install cfs-expo-auth0
```

### Getting Started

Configure the SDK by wrapping your application in `Auth0Provider`:

```js
// App.js
import { Auth0Provider } from "cfs-expo-auth0";
import React, { ReactElement } from "react";

import { Content } from "./Content";

export default function App() {
  return (
    <Auth0Provider
      clientId="YOUR_AUTH0_CLIENT_ID"
      audience="YOUR_AUTH0_API_AUDIENCE"
      domain="YOUR_AUTH0_DOMAIN"
      onLogin={() => {
        // Replace with your navigation code
      }}
      onTokenRequestFailure={() => {
        // Replace with your navigation code
      }}
    >
      <Content />
    </Auth0Provider>
  );
}
```

Use the `useAuth0` hook in your components to access authentication state (`user`, `accessToken`, `request` and `result`) and authentication methods (`login`):

```js
import { useAuth0 } from "cfs-expo-auth0";
import React from "react";

export default function HelloLogin() {
  const { user, result, login } = useAuth0();

  if (user) {
    return <div>Hello {user.name}</div>;
  }
  if (result?.type === "error") {
    return <div>Oops... an error occurred</div>;
  }

  return <button onClick={login}>Log in</button>;
}
```

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