Skip to content

useSigner

The useSigner hook returns the AlchemySigner instance created within the Accounts Context. This method is provided as a convenience for accessing the AlchemySigner instance directly. However, most operations involving the signer are exported via other hooks.

Import

ts
import { useSigner } from "@alchemy/aa-alchemy/react";

Usage

tsx
import { useSigner } from "@alchemy/aa-alchemy/react";

export function ComponentWithSigner() {
  const signer = useSigner();

  if (!signer) {
    return <div>Loading...</div>;
  }

  return (
    <div>
      <h1>Signer is ready!</h1>
      <div>{signer.inner.getUser()}</div>
    </div>
  );
}

Return Type

ts
import { type AlchemySigner } from "@alchemy/aa-alchemy";

Returns an instance of the AlchemySigner on the client and null on the server.