In this guide, we’ll look at how to build a frame using which people can create casts and perform other actions on the Farcaster app.
Click on Connect in the dashboard tab
In the modal select drivers as the connection method
Copy the connection string from here and replace `<password>` with your user password
.env
file and add the connection url that you just copied and replace the part after .mongodb.net/
with /db?retryWrites=true&w=majority
.
prisma/schema.prisma
and add a user model like this:
lib/prisma.ts
file in the src
folder and add the following:
layout.tsx
file and wrap your app in a NeynarContextProvider
like this:
clientId
, defaultTheme
and eventsCallbacks
.
clientId
: This is going to be the client ID you get from your neynar, add it to your .env.local
file as NEXT_PUBLIC_NEYNAR_CLIENT_ID
.defaultTheme
: default theme lets you change the theme of your sign-in button, currently, we have only light mode but dark mode is going to be live soon.eventsCallbacks
: This allows you to perform certain actions when the user signs out or auth is successful.page.tsx
file like this:
layout.tsx
add this to the onAuthSuccess
function in NeynarContextProvider
’s settings:
/api/add-user
API route which we are yet to create with the user’s signer and fid every time a user successfully signs in.
Now, create a new /api/add-user/route.ts
file in the app
folder and add the following:
neynarClient
function which we have not yet created so we have to do that. Create a new lib/neynarClient.ts
file and add the following:
frame/route.tsx
file in the app
folder and add the following:
start/route.tsx
in the frame
folder and add the following:
/frame/publish
route where the cast is made using the text that the user entered on the home screen.
Create a new file route.tsx
in the frame/publish/
folder and add the following:
publishCast
function from the client we initialised. If you try publishing a new cast on the frame it will create the cast and show you something like this.