🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

metanet-identity-react

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metanet-identity-react

React components for resolving identity information on the MetaNet.

latest
npmnpm
Version
0.1.78
Version published
Weekly downloads
34
325%
Maintainers
3
Weekly downloads
 
Created
Source

metanet-identity-react

React components for resolving identity information on the MetaNet.

The code is hosted on GitHub and the package is available through NPM.

Installation

npm i metanet-identity-react

Example Usage

import React, { useState } from 'react'
import { IdentitySearchField, Identity } from 'metanet-identity-react'

const IdentityDisplay: React.FC = () => {
  const [selectedIdentity, setSelectedIdentity] = useState<Identity | null>(null)

  return (
    <div>
         <IdentitySearchField onIdentitySelected={(identity) => {
            setSelectedIdentity(identity)
          }}/>
        {selectedIdentity && (
            <div>
                <h2>Selected Identity</h2>
                <p>Name: {selectedIdentity.name}</p>
                <p>Identity Key: {selectedIdentity.identityKey}</p>
            </div>
        )}
    </div>
  )
}

Example Headless Usage (useIdentitySearch Hook)

import { useIdentitySearch } from "metanet-identity-react"

const App = () => {
  
  const {
    identities,
    isLoading,
    setIsLoading,
    inputValue,
    setInputValue,
    selectedIdentity,
    setSelectedIdentity,
  } = useIdentitySearch()

  return (
    <>
      <div style={{ display: "flex", flexDirection: "column" }}>
        <input
          onChange={(e) => {
            setInputValue(e, e.target.value)
          }}
        />
        {isLoading ? (
          <p>Loading identities...</p>
        ) : (
          <>
            {inputValue !== "" && (
              <>
                {identities.map((identity, index) => {
                  return (
                    <button key={index}
                      onClick={(e) => {
                        setSelectedIdentity(e, identity)
                      }}
                    >
                      {identity.name}
                    </button>
                  )
                })}
              </>
            )}
          </>
        )}
        {selectedIdentity && (
          <>
            <h1>Selected Identity:</h1>
            <p>{selectedIdentity.name}</p>
            <img src={selectedIdentity.profilePhoto} width={64} />
            <p style={{ wordWrap: "break-word" }}>
              Identity Key: {selectedIdentity.identityKey}
            </p>
          </>
        )}
      </div>
    </>
  )
}

export default App

License

The license for the code in this repository is the Open BSV License.

FAQs

Package last updated on 14 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts