If using login providers like Privy, it’s best to use this signer product.
Users won’t see a double login and developers will get full write functionality to Farcaster.To get started immediately, you can clone this GitHub repository
Run the app as per the readme page in the repoContext
This guide covers setting up a Next.js backend server to create and use Neynar Managed Signers for publishing a cast on Farcaster. The backend will:- Create a signer for the user.
- Generate signature.
- Provide API routes for frontend interactions.
- Allow publishing casts on behalf of authenticated users.
The ideal user flow
Terminology To understand the ideal user flow, let’s quickly go over some terminology:- Authentication: This is where an account proves they are who they say they are. Flows like Sign in with Farcaster (SIWF) or login providers like Privy allow this for app logins.
- Authorization: this is where an account gives the app certain access privileges to take actions on behalf of the account. This is what Neynar signers allow for writing data to the protocol.
- SIWN: Connect Farcaster accounts
- or 3rd party login providers like Privy
- the 1st step on authentication happens on Privy login and the 2nd step of authorization happens on Neynar
- the second step requires the user to scan a QR code or tap on a link to then generate a signer on a Farcaster client like Warpcast. Generating a signer requires paying onchain fees
- Neynar sponsors signers by default so users pay $0.
Requirements
- Node.js (LTS recommended)
Installation
-
Next.js
-
Dependencies (to install via
npm
,yarn
, etc.): -
Environment Variables: Create a
.env.local
file in your Next.js project root and add:- NEYNAR_API_KEY: Get from Neynar Dashboard.
- FARCASTER_DEVELOPER_MNEMONIC: The mnemonic for your developer account on Farcaster. e.g.
@your_company_name
account on Farcaster (to state the obvious out loud, you won’t need user mnemonics at any point)
Directory Structure
Make the following directory structure in your codebase1. lib/neynarClient.ts
Copy the following into a file called lib/neynarClient.ts
2. utils/getFid.ts
Copy the following code into a file called utils/getFid.ts
3. utils/getSignedKey.ts
Copy the following code into a file called utils/getSignedKey.ts
createSigner
to create a signer, and then we use the appAccountKey.signKeyRequest
function from the @farcaster/hub-nodejs
package to create a sign key request. Finally, we use the registerSignedKey
function from the neynarClient to register the signedKey. registerSignedKey
returns signer_approved_url
that needs to be handled (More on this in step 7)
4. app/api/signer/route.ts
Copy the following code into app/api/signer/route.ts
5. app/api/cast/route.ts
Copy the following code into app/api/cast/route.ts
6. Run the app
Make sure nothing is running on port 3000. Ensure that your.env.local
file is correctly set up before running the application.
7. cURL /api/signer
signer_uuid
in the database or use fetchSigners api to fetch signers for the user (We recommend the latter method)
Convert signer_approved_url
to a QR code (For testing, you can use any online tool, e.g., QRFY)
If the user is using the application on desktop, then ask the user to scan this QR code. If the user is on mobile, ask them to click the link. This will deeplink the user into Warpcast, and they will see the following screenshot.

8. cURL /api/cast
Read more Two Ways to Sponsor a Farcaster Signer via Neynar to see how to sponsor a signer on behalf of the user
Conclusion
With this backend setup, your Next.js app can:- Generate Neynar Managed Signers for a single app. (
@your_company_name
account) - Provide API routes for frontend interactions to handle signers and publishing casts.