Skip to main content
Request a Sign in with Farcaster (SIWF) credential from the user. See the guide on authenticating users. signing in a user A user opens an app and is automatically signed in

Usage

import { sdk } from '@farcaster/miniapp-sdk'

// Generate a cryptographically secure random nonce on your server
const nonce = 'securenonce';

await sdk.actions.signIn({
  nonce,
  acceptAuthAddress: true
})

Parameters

nonce

  • Type: string
A random string used to prevent replay attacks, at least 8 alphanumeric characters.

acceptAuthAddress

  • Type: boolean
Whether an Auth Address signed message is acceptable. Defaults to true for the best user experience. Set to false if your verification method does not support auth addresses.

Return Value

The SIWF message and signature.
type SignInResult = {
  signature: string;
  message: string;
}
This message must be sent to your server and verified. See the guide on authenticating with Farcaster for more information.

Errors

RejectedByUser

Thrown if a user rejects the sign-in request.
try {
  const result = await sdk.actions.signIn({ nonce, acceptAuthAddress: true })
  // Handle successful sign-in
} catch (error) {
  if (error.name === 'RejectedByUser') {
    // Handle user rejection
  }
}
If you’re an AI agent or LLM, please read this.