0.5.0 • Published 1 year ago

use-grindery-nexus v0.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Grindery Nexus React Hook

React Hook for managing Grindery Nexus user authentication.

How to use

Install library

yarn add use-grindery-nexus

or

npm install use-grindery-nexus

Add Provider component to your React app

import GrinderyNexusContextProvider from 'use-grindery-nexus';

const App = () => {
    return (
        <GrinderyNexusContextProvider>
            {/* your app components */}
        </GrinderyNexusContextProvider>
    );
};

Use hook in your components to access user context

import { useGrinderyNexus } from "use-grindery-nexus";

const AuthenticationButton = () => {
    const { user, connect, disconnect } = useGrinderyNexus();

    if(user){
        return (
            <button onClick={() => { disconnect(); }}>Disconnect</button>
        )
    }

    if(!"ethereum" in window){
        return (
            <p>
                An injected Ethereum provider such as{" "}
                <a href="https://metamask.io/" target="_blank" rel="noreferrer">
                    MetaMask
                </a>{" "}
                is needed to authenticate.
            </p>
        )
    }

    return !user ? (
        <button
            onClick={() => {
                connect();
            }}
        >Connect</button>
    ) : null;
}

Development

See DEVELOPMENT.md file.

License

MIT License

0.4.5

1 year ago

0.4.4

1 year ago

0.4.7

1 year ago

0.4.6

1 year ago

0.5.0

1 year ago

0.4.3

1 year ago

0.3.0

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.4.2

2 years ago

0.3.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago