UNPKG

@nfid/identitykit

Version:

A React library for adding wallet connections to dApps.

148 lines (101 loc) β€’ 4.73 kB
# NFID IdentityKit NFID IdentityKit is a React library designed to simplify adding a wallet connection to your decentralized application (dApp). With intuitive, responsive, and customizable components, developers can easily select which ICP-compatible wallets to support in their apps for authentication, signatures, and transfers. ## πŸ“š Table of Contents - [✨ Features](#-features) - [πŸ›  Prerequisites](#-prerequisites) - [πŸ“¦ Installation](#-installation) - [πŸ”— Peer Dependencies](#-peer-dependencies) - [πŸš€ Usage](#-usage) - [🎨 Import Styles](#-import-styles) - [🧩 Wrap Your Application with `IdentityKitProvider`](#-wrap-your-application-with-identitykitprovider) - [πŸ”— Add the Connect Button](#-add-the-connect-button) - [πŸ”¬ Playground](#-playground) - [πŸ“„ License](#-license) - [🀝 Contributing](#-contributing) - [πŸ’¬ Support](#-support) - [πŸ“˜ Documentation](#-documentation) - [πŸŽ‰ Try it out](#-try-it-out) ## ✨ Features - **Easy Integration:** Quickly add wallet connection functionality to your dApp. - **Customizable:** Tailor the look and feel to match your application's design. - **Responsive:** Optimized for different screen sizes and devices. ## πŸ›  Prerequisites Before using NFID IdentityKit, ensure that you have: - An ICP project with a frontend canister. ## πŸ“¦ Installation A library to integrate compatible ICP wallets into your application, which contains React-specific components for integrating compatible ICP wallets into your application. Install library with the following command: ```sh npm2yarn npm install @nfid/identitykit ``` ### πŸ”— Peer Dependencies IdentityKit requires certain peer dependencies to function correctly. Ensure the following packages are installed in your project: ```sh npm2yarn npm install @dfinity/ledger-icp @dfinity/identity @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils @dfinity/auth-client ``` **Note:** IdentityKit is a React library and exports styles that need to be imported into your project. ## πŸš€ Usage ### 🎨 Import Styles Begin by importing the necessary styles in your project: ```javascript import "@nfid/identitykit/react/styles.css" ``` ### 🧩 Wrap Your Application with `IdentityKitProvider` Next, wrap your entire application with the `IdentityKitProvider` to enable wallet connections: ```javascript import { IdentityKitProvider } from "@nfid/identitykit/react" const App = () => { return ( <IdentityKitProvider> <YourApp /> </IdentityKitProvider> ) } ``` ### πŸ”— Add the Connect Button Finally, import and render the `ConnectWallet` component in your application to allow users to connect their wallets: ```javascript import { ConnectWallet } from "@nfid/identitykit/react" export const YourApp = () => { return <ConnectWallet /> } ``` Once integrated, IdentityKit will handle your user's wallet selection, display wallet information, and manage wallet switching. ## πŸ”¬ Playground IdentityKit comes with its own playground where you can try things out locally. There are three applications included: 1. `dApp` (react-dapp) - Built for signer developers, this app provides a web-based interface to visually explore the API documentation for IdentityKit standards. It runs on port 3001. Check it out at https://qzjsg-qiaaa-aaaam-acupa-cai.icp0.io/standards 2. `Demo` (react-demo) - This app is for application developers. It's a simple frontend app with IdentityKit integrated. It runs on port 3002 and lets you sign in with IdentityKit and make canister calls. Check it out at https://qzjsg-qiaaa-aaaam-acupa-cai.icp0.io/demo 3. `Signer` (react-signer) - This is a sample signer app that demonstrates the basics of signer functionality. It helps to understand what’s happening on the signer side. It runs on port 3003. To get the playground up and running, use the following command: ```sh npm i && npm run playground ``` ## πŸ“„ License This project is licensed under the MIT License. ## 🀝 Contributing Contributions are welcome! To get started, please submit a pull request or open an issue on [GitHub](https://github.com/internet-identity-labs/identitykit). ## πŸ’¬ Support If you encounter any issues or have questions, feel free to reach out to the team directly on [Discord](https://discord.gg/bJK5HE6KDn). ## πŸ“˜ Documentation For full documentation, visit https://qzjsg-qiaaa-aaaam-acupa-cai.icp0.io/docs. ## πŸŽ‰ Try it out Here is a short list of live IdentityKit implementations: - [Demo App](https://qzjsg-qiaaa-aaaam-acupa-cai.icp0.io/demo) - [ICRC Standards Implementation](https://qzjsg-qiaaa-aaaam-acupa-cai.icp0.io/standards) (view low-level ICRC standards implementations)