# @ivyhjk/amplify-react-native-social-auth

> React Native social authentication wrapper for amplify

Latest version **1.0.0-next.2** (published 2021-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ivyhjk/amplify-react-native-social-auth
pnpm add @ivyhjk/amplify-react-native-social-auth
yarn add @ivyhjk/amplify-react-native-social-auth
bun add @ivyhjk/amplify-react-native-social-auth
```

## 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.0.0-next.2 |
| Published | 2021-01-03 |
| First published | 2021-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Elvis Munoz |
| Maintainers | ivyhjk |

## Links

- npm: https://www.npmjs.com/package/@ivyhjk/amplify-react-native-social-auth
- Repository: https://github.com/ivyhjk/amplify-react-auth
- Homepage: https://github.com/ivyhjk/amplify-react-auth/tree/master/packages/native-social#readme
- Issues: https://github.com/ivyhjk/amplify-react-auth/issues
- npm.io page: https://npm.io/package/@ivyhjk/amplify-react-native-social-auth

## Dependencies (3)

- [@ivyhjk/amplify-react-core-auth](https://npm.io/package/@ivyhjk/amplify-react-core-auth.md) ^1.0.0-next.1
- [@ivyhjk/amplify-react-federated-auth](https://npm.io/package/@ivyhjk/amplify-react-federated-auth.md) ^1.0.0-next.1
- [@react-native-community/google-signin](https://npm.io/package/@react-native-community/google-signin.md) ^5.0.0

## Recent versions

- 1.0.0-next.2 (latest) — 2021-01-03
- 1.0.0-next.10 (next) — 2021-09-04
- 1.0.0-next.8 — 2021-04-02
- 1.0.0-next.7 — 2021-04-02
- 1.0.0-next.6 — 2021-04-02
- 1.0.0-next.5 — 2021-04-02
- 1.0.0-next.3 — 2021-01-07

## README

# React Native Amplify social authentication

React Native social authentication based on top of AWS Amplify

## Install

with NPM:

```bash
npm install @ivyhjk/amplify-react-native-social-auth
```

with yarn:

```bash
yarn add @ivyhjk/amplify-react-native-social-auth
```

## Usage

Put the context in your main application component:

```tsx
import { SocialAuthProvider } from '@ivyhjk/amplify-react-native-social-auth';

const App: React.Fc = () => (
  <SocialAuthProvider>
    {/* ... */}
  </SocialAuthProvider>
);
```

### Hooks

**Sign in with Google**:

```tsx
import { useGoogleSignIn } from '@ivyhjk/amplify-react-native-social-auth';
import { Button, Text, View } from 'react-native';

const Component: React.FC = () => {
  const [doGoogleSignIn, { loading, error, user }] = useGoogleSignIn();

  const handleGoogleSignIn = React.useCallback(() => {
    doGoogleSignIn();
  }, [doGoogleSignIn]);

  if (error) {
    return (
      <View>
        <Text>Error: {error.message}</Text>
      </View>
    );
  }

  if (user) {
    return (
      <View>
        <Text>welcome, {user.name}</Text>
      </View>
    );
  }

  return (
    <View>
      <Button disabled={loading} onPress={handleGoogleSignIn}>
        Google SignIn
      </Button>
    </View>
  );
};
```

**Sign out from Google**:

```tsx
import { useGoogleSignOut } from '@ivyhjk/amplify-react-native-social-auth';
import { Button, Text, View } from 'react-native';

const Component: React.FC = () => {
  const [doGoogleSignOut, { loading, error, user }] = useGoogleSignOut();

  const handleGoogleSignOut = React.useCallback(() => {
    doGoogleSignOut();
  }, [doGoogleSignOut]);

  if (error) {
    return (
      <View>
        <Text>Error: {error.message}</Text>
      </View>
    );
  }

  return (
    <View>
      {user && <Text>welcome, {user.name}</Text>}
      <Button disabled={loading} onPress={handleGoogleSignOut}>
        Google SignOut
      </Button>
    </View>
  );
};
```

**Get the current authenticated user, directly from amplify, without cache**:

```tsx
import { useCurrentAuthenticatedUser } from '@ivyhjk/amplify-react-native-social-auth';
import { Text, View } from 'react-native';

const UserComponent: React.FC = () => {
  const { error, loading, user } = useCurrentAuthenticatedUser();

  return (
    <View>
      <Text>
        Welcome {user.name}
      </Text>
    </View>
  );
}
```

**Get the current authenticated user, from context (fastest)**:

```tsx
import { useUser } from '@ivyhjk/amplify-react-native-social-auth';
import { Text, View } from 'react-native';

const UserComponent: React.FC = () => {
  const user = useUser();

  return (
    <View>
      <Text>
        Welcome {user.name}
      </Text>
    </View>
  );
}
```

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