useSigner â
The useSigner
hook provides access to the transaction signer from the connected wallet, which is required for signing and submitting transactions.
Import â
import { useSigner } from '@luno-kit/react'
Usage â
Basic Usage â
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>
)
}
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 â
Property | Type | Description |
---|---|---|
data | Signer | undefined | The transaction signer from the connected wallet |
isLoading | boolean | Whether the signer is currently being loaded |
Related Types â
Signer â
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 blockchainsignRaw
: 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).
Feature | useSigner | usePapiSigner |
---|---|---|
Compatibility | LunoKit transaction hooks | PAPI |
Use case | When using LunoKit for transactions | When integrating with existing papi code |
Return value | Includes only the signer | Includes only the signer |
Required setup | Needs chains in config | Works 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.
Related Hooks â
usePapiSigner
- Get a papi-compatible signeruseSendTransaction
- Send transactions using the signeruseSignMessage
- Sign messages using the signer