Skip to content

useSigner ​

The useSigner hook provides access to the transaction signer from the connected wallet, which is required for signing and submitting transactions.

Import ​

tsx
import { useSigner } from '@luno-kit/react'

Usage ​

Basic Usage ​

tsx
import { useSigner } from '@luno-kit/react'

function ConditionalSigner() {
  const { data: signer, isLoading } = useSigner()

  if (isLoading) {
    return <div>âŗ Loading signer...</div>
  }

  if (!signer) {
    return <div>â„šī¸ Please connect a wallet to access the signer</div>
  }

  return (
    <div>
      <h3>✅ Signer Ready</h3>
      <p>You can now sign transactions and messages</p>
    </div>
  )
}
ts
import { createConfig } from '@luno-kit/react'
import { polkadot, kusama } from '@luno-kit/react/chains'
import { polkadotjsConnector } from '@luno-kit/react/connectors'

const config = createConfig({
  appName: 'luno with-vite example',
  chains: [polkadot, kusama],
  connectors: [polkadotjsConnector()],
  autoConnect: true,
});

Return Value ​

The hook returns an object with the following properties:

Data & Status ​

PropertyTypeDescription
dataSigner | undefinedThe transaction signer from the connected wallet
isLoadingbooleanWhether the signer is currently being loaded

Signer ​

tsx
import type { InjectedSigner } from 'dedot/types';

interface Signer extends InjectedSigner {
  // Inherits all properties and methods from InjectedSigner
}

The Signer interface provides methods for:

  • signPayload: Signs transaction payloads for submission to the blockchain
  • signRaw: Signs arbitrary messages or data with the connected account

TIP

This hook automatically manages the signer lifecycle. It will attempt to retrieve the signer whenever the active connector or account changes. The signer is required for most transaction-related operations in LunoKit.

Differences from usePapiSigner ​

The useSigner hook provides a LunoKit-compatible signer for use with LunoKit's transaction hooks, while the usePapiSigner hook provides a signer that's compatible with the Polkadot API (papi).

FeatureuseSignerusePapiSigner
CompatibilityLunoKit transaction hooksPAPI
Use caseWhen using LunoKit for transactionsWhen integrating with existing papi code
Return valueIncludes only the signerIncludes only the signer
Required setupNeeds chains in configWorks with chains-free config

Choose useSigner when using LunoKit's transaction hooks like useSendTransaction, and choose usePapiSigner when you need to integrate with existing code that uses the PAPI directly.

Released under the MIT License.