useSigner
Hook for getting the current signer of the connected wallet, if one is available.
Useful if you want to instantiate an instance of the ThirdwebSDK with the signer of the connected wallet in the TypeScript SDK, or using other web3 libraries that require a signer such as Ethers with the React SDK.
import { useSigner } from "@thirdweb-dev/react";
Usage
Returns the Signer
of the connected wallet, if one is available.
If no wallet is connected, returns undefined
.
import { useSigner, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const signer = useSigner();
}
Return Value
The hook's return type is Signer | undefined
where Signer
is the EthersJS signer instance.
Signer | undefined;