Skip to content

usePapiSigner ​

The usePapiSigner hook provides a signer object compatible with the Polkadot API (papi), allowing you to use LunoKit's wallet connection features with your existing papi implementation.

Import ​

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

Usage ​

Basic Usage ​

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

function ConditionalPapiSigner() {
  const { data: papiSigner, isLoading } = usePapiSigner()

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

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

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

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

Configuration ​

Minimal Setup ​

To use usePapiSigner, you need to set up LunoKit with just the wallet connection features:

tsx
import { createConfig } from '@luno-kit/react'
import { LunoKitProvider } from '@luno-kit/ui';
import { polkadotjsConnector } from '@luno-kit/react/connectors'

// Create a config without chains
const config = createConfig({
  appName: 'My papi Dapp',
  connectors: [polkadotjsConnector()],
})

function App() {
  return (
    <LunoKitProvider config={config}>
      <ConditionalPapiSigner />
    </LunoKitProvider>
  )
}

Return Value ​

The hook returns an object with the following properties:

Data & Status ​

PropertyTypeDescription
dataPapiSigner | undefinedA papi-compatible signer object
isLoadingbooleanWhether the signer is being loaded

PapiSigner ​

tsx
import type { PolkadotSigner as PapiSigner } from '@polkadot-api/pjs-signer';

export type { PapiSigner };

TIP

Inherits from: PolkadotSigner from papi. For more details, see the papi signers documentation.

The PapiSigner interface provides:

  • publicKey: The public key of the signer
  • signBytes: Method for signing arbitrary bytes/messages
  • signTx: Method for signing transactions

TIP

This hook automatically manages the signer lifecycle. It will attempt to retrieve a papi-compatible signer whenever the active connector or account changes.

Differences from useSigner ​

The usePapiSigner hook provides a signer that's compatible with the PAPI, while the useSigner hook provides a LunoKit-compatible signer for use with LunoKit's transaction hooks.

FeatureusePapiSigneruseSigner
CompatibilityPAPILunoKit transaction hooks
Use caseWhen integrating with existing papi codeWhen using LunoKit for transactions
Return valueIncludes only the signerIncludes only the signer
Required setupWorks with chains-free configNeeds chains in config

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

Released under the MIT License.