Neynar Documentation

Setting up your application

Prerequisites

Cloning the repo

Clone the repo from GitHub using the following command and open it up in your favourite code editor using the following commands:

npx degit https://github.com/neynarxyz/farcaster-examples/tree/main/wownar-react-native react-native-siwn
cd react-native-siwn

Once you’ve cloned your repo we can start installing the packages and setting up the env variables!

Server

  1. Navigate to server directory

Navigate to the server directory

cd server
  1. Install Project Dependencies

Based on the package manager run one of the following commands to install all required dependencies:

npm

npm i

yarn

yarn install

pnpm

pnpm i

bun

bun i
  1. Configure Environment Variables

Copy the example environment file:

cp .env.example .env

Edit .env to add your NEYNAR_API_KEY and NEYNAR_CLIENT_ID. You can find them in your dashboard

  1. Start the server

Start the server:

npm

npm run start

yarn

yarn start

pnpm

pnpm run start

bun

bun run start

Client

Open new terminal

  1. Navigate to client directory

Navigate to the client directory

cd client
  1. Install Project Dependencies

Based on the package manager run one of the following commands to install all required dependencies:

For yarn

yarn install

For npm

npm install
  1. Configure Environment Variables

Copy the example environment file:

cp .env.example .env
  1. Start the app

Make sure your phone and computer is connected to the same network

For yarn

yarn start

For npm

npm run start

you’ll see a QR Code

  1. Run App

Open the Expo Go app on your phone and scan the QR Code. You should now be able to see a button to sign in with neynar in your app!

How does it work?

You’re probably wondering how it all works, so let’s break it down!

Server

In our server, we have 3 API routes, you can take a look at them in server/index.js:

Client

On the client side, we use the NeynarSigninButton component from the @neynar/react-native-signin package and pass in a bunch of props like fetchAuthorizationUrl, successCallback, errorCallback, and redirectUrl.

Conclusion

This guide taught us how to add sign-in with neynar to a React native app, check out the GitHub repository. Lastly, make sure to share what you built with us on Farcaster by tagging @neynar and if you have any questions, reach out to us on warpcast or Slack!