Prerequisites
Before you begin, confirm the following:Next.js Project Structure
Next.js Project Structure
You are using a Next.js project with the
app/ directory structure (App Router).Deployment
Deployment
Your app is deployed and publicly accessible (e.g. via Vercel) with HTTPS
enabled.
Farcaster Account
Farcaster Account
You have an active Farcaster account for testing and access to your custody
wallet.
Coinbase Developer Platform Account
Coinbase Developer Platform Account
Sign up for a Coinbase Developer Platform to retrieve your CDP API Key.
Integration Steps
Install required dependencies
MiniKit is available as part of OnchainKit.
Verify installation by checking that
@coinbase/onchainkit appears in your package.json.Add the MiniKitProvider to your app
Create and use the Then wrap your app in
MiniKitProvider to initialise SDK context for your application.File: providers/MiniKitProvider.tsxapp/layout.tsx:Initialize MiniKit in your main page
Use the
useMiniKit hook to access the frame context and trigger readiness.File: app/page.tsxThe
setFrameReady() function removes the splash screen and shows your application. Only call this when your app is fully loaded and ready for user interaction.Configure environment variables
Add the required environment variables to your project and deployment platform.
- Required Variables
- Optional Variables
These variables are essential for your MiniKit app to function:
The name of your Mini App as it appears to users
The deployed URL of your application (must be HTTPS)
Your Coinbase Developer Platform API key
Generated during manifest creation for account association
Generated during manifest creation for account association
Generated during manifest creation for account association
Generate the manifest
Use the OnchainKit CLI to generate account association credentials and update your environment variables.Follow these substeps:
Important: The wallet you connect must be your Farcaster custody wallet.
You can import this wallet using the recovery phrase found in Farcaster under
Settings → Advanced → Farcaster recovery phrase.
- Connect your Farcaster custody wallet
- Add your deployed Vercel URL
- Sign the manifest to generate association credentials
- The CLI will automatically update your local
.envfile
Create .well-known/farcaster.json route
The farcaster.json file contains metadata that allows clients to identify your Mini App and its capabilities.Create a route handler at
app/.well-known/farcaster.json/route.ts:Test this endpoint by visiting
https://yourdomain.com/.well-known/farcaster.json to ensure it returns valid JSON.Define Farcaster frame metadata
Configure the metadata that clients use to render your Mini App in posts and generate preview cards.File:
app/layout.tsxTest and deploy your Mini App
Before sharing your Mini App, validate that everything is working correctly.
- Pre-deployment Checklist
- Validation Tools
Verify the following before going live:
- ✅ App is deployed at a public HTTPS domain
- ✅ All environment variables are set on your deployment platform
- ✅ All referenced images are accessible in your
public/folder - ✅ The
.well-known/farcaster.jsonendpoint returns valid JSON - ✅ Your app loads without errors in a browser
Need Help Debugging?
If you encounter issues, check our comprehensive debugging guide for common problems and solutions.
Understanding MiniKit Context
What useMiniKit Gives You
The useMiniKit() hook provides access to everything your Mini App needs to understand the Farcaster session:
The Farcaster ID of the current user
Whether the user has added your Mini App to their account
Where the app was launched from (e.g., “cast”, “launcher”, “notification”)
Whether your app has called
setFrameReady() and is ready to be shownFunction to call when your app is fully loaded and ready for interaction
Available MiniKit Hooks
MiniKit provides a comprehensive set of hooks designed to help you build rich, social experiences:useNotification
Send in-app and push notifications to users who have added your frame
useAddFrame
Allow users to save your mini app to their Farcaster client for easy access
useClose
Programmatically close the mini app frame when appropriate
useOpenUrl
Open external URLs from within the frame context
usePrimaryButton
Configure and handle primary button interactions
useViewProfile
Navigate users to Farcaster profiles (their own or others)
useAuthenticate
Handle Farcaster authentication and sign-in flows
Explore All Hooks
Learn about all available MiniKit hooks, their parameters, and usage examples
Next Steps
Now that your Mini App is integrated and deployed:Monitor and iterate
Use analytics to understand how users interact with your app and identify
areas for improvement.