Skip to content

Integrating Farcaster login

Farcaster is a sufficiently decentralized social network whose core social graph is stored on-chain. Users can choose how content they create is stored and it enables unique, composable experiences by enabling users to link their accounts with a wallet of their choosing.

Privy enables your users to easily log in to your app using their Farcaster account. This means you can easily integrate Privy with Farcaster to compose experiences with a user's existing social graph or network.

Here's how!

TIP

Log in with Farcaster enables log in and read access to a user's Farcaster account but does not provide write access to the account today.

How does Farcaster login work?

Farcaster identifies users via a signer: this is an EdDSA keypair that is used by the client application to sign content like posts ("casts"), follows, etc on behalf of users.

These Farcaster signers are managed through various clients such as Warpcast, Supercast and others.

Privy uses a standard called Sign in with Farcaster (FIP-11) to issue a signature request to a user's Farcaster account via the client a user has. Warpcast is currently supported.


1. Enable Farcaster login in your console

Go to your app in your developer dashboard and click on Login methods in the left navigation bar. From here, enable Farcaster as a social option.

This will enable you to configure Farcaster as a login and account linking option in your app.

2. Configure your app's Farcaster integration

The following assumes you have set up Privy with your app. If you haven't, start by following the instructions in the Privy Quickstart to get your app set up with Privy.

From there, if you'd like users to be able to login to your app with their Farcaster account, you can configure 'farcaster' as an upfront login method in your PrivyProvider, like so:

tsx
<PrivyProvider
  appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID}
  config={{
    // This configures email, farcaster and wallet login for your app.
    appearance: {
        loginMethods: ['farcaster', ...insertTheRestOfYourLoginMethods]
    },
    ...insertTheRestOfYourPrivyProviderConfig
  }}
>

You can also prompt existing users to link their Farcaster account to their existing account.

tsx
import {usePrivy} from '@privy-io/react-auth';

function Page() {
  const {linkFarcaster} = usePrivy();
  // You may replace this hook with any of the other `link-` hooks to
  // link a different account type.
  return <button onClick={linkFarcaster}>Link your Farcaster</button>;
}

Once a user has logged in with or linked their Farcaster account, you can find their Farcaster object, including their fid, username, pfp and more, in the user object returned by the usePrivy hook.

That's it! Once you've linked a Farcaster account to a user object, you can use this to power composable experiences in your app. You should also consider using toolkits like Farcaster's APIs, Airstack, or Neynar to query and interact with protocol data.

TIP

Farcaster login and linking currently only providers read access to Farcaster accounts. We are actively building support for write access to the protocol as well.

If you have any feedback or ideas, please reach out via our Developer Slack -- we'd love to work with you on this!