useClickRef() hook

In your components, you'll often need to call the CSPR.click API to get data or request an operation. To get a reference to the CSPR.click SDK instance make use of the useClickRef() React hook:

import { useClickRef } from '@make-software/csprclick-react';

function MyComponent() {
  const clickRef = useClickRef();
  ...
}

Then, in your application you'll be able to request CSPR.click to perform some operations using the class methods, or get values reading the class properties.

Common methods

One of the benefits of using the UI SDK is that it provides the UI and the logic to handle common situations like showing the sign-in options, interacting with the wallets, switching from one account to another, and many more. Therefore, you'll often be using a reduced set of CSPR.click methods in your application. Let's review the most common ones:

  • signIn(). Shows the connection options to start a user's session.

  • signOut(). Closes your user's session.

  • getActiveAccount(). Returns the active account data.

  • getActivePublicKey(). Returns the connected public key.

  • switchAccount(). Displays to the user a modal dialog to switch to another account when the user session is open.

  • sign(). Triggers the process to request the user the signature of a transaction.

  • send(). Similar to sign(), but when the transaction is signed, sends it to a Casper node for its processing.

  • signMessage(). Triggers the process to request the user the signature of a message.

Last updated