npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-oneid

v1.0.5

Published

React hook for OneID SDK

Readme

OneID SDK React hook

NPM

For more information on OneID and its features, see the documentation.

📲 Installation

In your React application, install react-oneid using the following command:

npm install --save react-oneid

🏃🏽‍♂️ Quick Start

Wrap your app with OneidProvider, and provide your apiKey and siteDomain.

import React from "react";
import ReactDOM from "react-dom";
import { OneidProvider } from "react-oneid";

ReactDOM.render(
  <OneidProvider apiKey="xxxxxxxx" siteDomain="<http/https>://xxxxxxxx">
    <App />
  </OneidProvider>,
  document.getElementById("root"),
);

And call the hooks inside your app:

import React, { useEffect, useState } from "react";
import { useOneid } from "react-oneid";

function App() {
  const [loggedIn, setLoggedIn] = useState(false)
  const [user, setUser] = useState()
  const { handleAuth, isAuthenticated, currentUser, logOut } = useOneid();

  useEffect(() => {
    if(isAuthenticated()) {
      setLoggedIn(true)
      currentUser().then(data => setUser(data.user))
    }
    else{
      setLoggedIn(false)
    }
  }, [isAuthenticated()])


  if (!loggedIn) {
    return (
      <div>
        <button onClick={() => handleAuth({type: "login", scope: "profile"})}>Authenticate</button>
      </div>
    );
  }

  return (
    <div>
    <h1>Welcome {user && user.email}</h1>

      <div>
        <button onClick={() => logOut()}>Logout</button>
      </div>
    </div>
  );
}

export default App

🧭 Table of content

💻 Usage

Wrap your app in OneidProvider

In order to let your components have access to OneId functions, wrap your app in a <OneidProvider></OneidProvider> component. This will handle the whole initialization for you. You need to provide the apiKey and siteDomain, which can be obtained from your OneID dashboard.

<OneidProvider apiKey="xxxxxxxx" siteDomain="<http/https>://xxxxxxxx">
  <App />
</OneidProvider>

This component will automatically initialize OneId with the provided apiKey and siteDomain. It will also keep the authentication of the user automatically in sync and easy accessible (see useOneid), and give access to all the other hooks.

Now you can use the hooks below in all App.tsx and all of its children:

  • useOneid - A group of functions as a single hook.
  • ...

useOneid

The useOneid hook provides all the basics functionalities that you need for authentication and user data.

You can use it inside a component and have access to various data and functions:

const { handleAuth, isAuthenticated, currentUser, logOut } = useOneid()

You will have access to the following values by using this hook:

| Option | Description | | ------- | ----------- | | handleAuth | This accepts two parameters: { type: "login"\| "signup", scope: "profile" \| "basic" \| "advance" }| | isAuthenticated | This returns a Boolean vaule| | currentUser | This returns an object - { token: string, user: {...userProfile} } | | logOut | This clear the currently authenticated user from the instance of the application and localstorage |

⌨️ Typescript

This library offers first-class Typescript support.

🧑‍💻 Development

Make sure to have node installed.

  • Clone this repo
  • Run the following command in the directory of the clone:
  cd react-oneid
  npm install

Please follow the code guidelines before submitting a PR.

Make sure the code is clear and readable Adhere to the style rules of Eslint, Prettier and Conventional Commit

✔ License

MIT © wolz-codelife


This hook is created using create-react-hook.