# @id6/react

> id6 react integration

Latest version **1.0.2** (published 2021-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @id6/react
pnpm add @id6/react
yarn add @id6/react
bun add @id6/react
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-04-21 |
| First published | 2021-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 15.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | id6 |
| Maintainers | id6io, gempain |

## Links

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

## Recent versions

- 1.0.2 (latest) — 2021-04-21

## README

<p align="center">
  <a href="https://id6.io">
    <img alt="id6-logo" src="https://raw.githubusercontent.com/id6/id6-brand/latest/logo/id6-logo-purple.svg" width="100"/>
  </a>
</p>
<h1 align="center">id6-react</h1>
<p align="center">React integration for id6</p>

<p align="center">
  <img alt="npm" src="https://img.shields.io/npm/v/@id6/react">
</p>

## Install

```bash
npm install --save @id6/react
```

## Usage

```tsx
import React from 'react'
import { AuthProvider, useAuth } from '@id6/react'

function Home() {
  const { loading, error, user, signOut } = useAuth();

  const logout = () => {
    signOut().catch(console.error);
  };

  return loading ? (
    <p>Loading...</p>
  ) : error ? (
    <p>Error: {error.message}</p>
  ) : (
    <div>
      {user ? (
        <p>
          Signed in as {user.name}
          <button type="button" onClick={logout}>Sign out</button>
        </p>
      ) : (
        <a href={process.env.REACT_APP_ID6_LOGIN_URL}>Sign in</a>
      )}
    </div>
  );
}

function App() {
  return (
    <AuthProvider url="http://id6.company.com">
      <Home/>
    </AuthProvider>
  );
}
```

## Development

```bash
npm i
npm start
```

To test the example app:

``` bash
cd example
npm i
npm start
```

## License

MIT © [id6](https://github.com/id6)

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