0.0.12 • Published 3 years ago

@bendcircular/react-ic-ii-auth v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-ic-ii-auth


⚠️ DEPRECATED ⚠️

use @identity-labs/react-ic-ii-auth insead


React components to use DFINITY Internet Identity Authentication

NPM JavaScript Style Guide

Install

npm install --save @bendcircular/react-ic-ii-auth

Usage

import React from 'react'

import {
  InternetIdentityProvider,
  useInternetIdentity
} from '@bendcircular/react-ic-ii-auth'

const AuthButthon = () => {
  const { authenticate, isAuthenticated, identity } = useInternetIdentity()
  console.log('>> initialize your actors with', { identity })
  return (
    <button onClick={authenticate}>
      {isAuthenticated ? 'Logout' : 'Login'}
    </button>
  )
}

const App = () => {
  return (
    <InternetIdentityProvider
      authClientOptions={{
        onSuccess: (identity) => console.log(
          ">> initialize your actors with", {identity}
        )
        // NOTE: Overwrite identityProvider in dev mode
        // defaults to "https://identity.ic0.app/#authorize"
        identityProvider: `http://${process.env.II_CANISTER_ID}.localhost:8000/#authorize`
      }}
    >
      <AuthButthon />
    </InternetIdentityProvider>
  )
}

export default App

Inspired by:

License

MIT © bendcircular GmbH

0.0.11

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago