Skip to main content
Hook for signing in a user. Connects to the relay server, generates a sign in link to present to the user, and polls the relay server for the user’s Farcaster wallet signature. If you want to build your own sign in component with a custom UI, use the useSignIn hook.
import { useSignIn, QRCode } from '@farcaster/auth-kit';

function App() {
  const {
    signIn,
    url,
    data: { username },
  } = useSignIn({
    onSuccess: ({ fid }) => console.log('Your fid:', fid),
  });

  return (
    <div>
      <button onClick={signIn}>Sign In</button>
      {url && (
        <span>
          Scan this: <QRCode uri={url} />
        </span>
      )}
      {username && `Hello, ${username}!`}
    </div>
  );
}

Parameters

ParameterTypeDescriptionDefault
timeoutnumberReturn an error after polling for this long.300_000 (5 minutes)
intervalnumberPoll the relay server for updates at this interval.1500 (1.5 seconds)
noncestringA random nonce to include in the Sign In With Farcaster message.None
notBeforestringTime when the SIWF message becomes valid. ISO 8601 datetime string.None
expirationTimestringTime when the SIWF message expires. ISO 8601 datetime string.None
requestIdstringAn optional system-specific ID to include in the SIWF message.None
onSuccessfunctionCallback invoked when sign in is complete and the user is authenticated.None
onStatusResponsefunctionCallback invoked when the component receives a status update from the relay server.None
onErrorfunctionError callback function.None

Returns

  {
    signIn: () => void;
    signOut: () => void;
    connect: () => void;
    reconnect: () => void;
    isConnected: boolean;
    isSuccess: boolean;
    isPolling: boolean;
    isError: boolean;
    error: AuthClientError;
    channelToken: string;
    url: string;
    appClient: AppClient;
    data: {
        state: "pending" | "complete";
        nonce: string;
        message: string;
        signature: Hex;
        fid: number;
        username: string;
        bio: string;
        displayName: string;
        pfpUrl: string;
        custody?: Hex;
        verifications?: Hex[];
    },
    validSignature: boolean;
  };
ParameterDescription
signInCall this function following connect to begin polling for a signature.
signOutCall this function to clear the AuthKit state and sign out the user.
connectConnect to the auth relay and create a channel.
reconnectReconnect to the relay and try again. Call this in the event of an error.
isConnectedTrue if AuthKit is connected to the relay server and has an active channel.
isSuccessTrue when the relay server returns a valid signature.
isPollingTrue when the relay state is "pending" and the app is polling the relay server for a response.
isErrorTrue when an error has occurred.
errorAuthClientError instance.
channelTokenConnect relay channel token.
urlSign in With Farcaster URL to present to the user. Links to the Farcaster client in v1.
appClientUnderlying AppClient instance.
data.stateStatus of the sign in request, either "pending" or "complete"
data.nonceRandom nonce used in the SIWE message. If you don’t provide a custom nonce as an argument to the hook, you should read this value.
data.messageThe generated SIWE message.
data.signatureHex signature produced by the user’s Farcaster client app wallet.
data.fidUser’s Farcaster ID.
data.usernameUser’s Farcaster username.
data.bioUser’s Farcaster bio.
data.displayNameUser’s Farcaster display name.
data.pfpUrlUser’s Farcaster profile picture URL.
data.custodyUser’s FID custody address.
data.verificationsList of user’s verified addresses.
validSignatureTrue when the signature returned by the relay server is valid.