@freevuehub/reacth
TypeScript icon, indicating that this package has built-in type declarations

1.2.6 • Public • Published

Reacth (React-Auth)

Installation

NPM: npm install @freevuehub/reacth --save

Yarn: yarn add @freevuehub/reacth

Usage

Google

import React from 'react'
import { Google } from '@freevuehub/reacth'

const CLIENT_KEY = '<Google OAuth Client Key>'
const App: React.FC = (props) => {
  return (
    <Google.Provider client-key={CLIENT_KEY}>
      {props.children}
    </Google.Provider>
  )
}
import React, { useContext } from 'react'
import { Google } from '@freevuehub/reacth'

const Home: React.FC = (props) => {
  const { signIn, signOut, user } = useContext(Google.Context)
  
  const onSignInClick = async (event: React.MouseEvent<HTMLButtonElement>) => {
    event.preventDefault()
    
    await signIn()
  }
  const onSignOutClick = async (event: React.MouseEvent<HTMLButtonElement>) => {
    event.preventDefault()

    await signOut()
  }
  
  return (
    <>
      <div>
        <button onClick={onSignInClick}>Sign In</button>
        <button onClick={onSignOutClick}>Sign Out</button>
      </div>
      <h1>{user.name}</h1>
    </>
  )
}

User Response Data

Key Type
id Int
name String
email String
image String

Package Sidebar

Install

npm i @freevuehub/reacth

Weekly Downloads

0

Version

1.2.6

License

MIT

Unpacked Size

34.5 kB

Total Files

39

Last publish

Collaborators

  • freevuehub