Integrating MiniKit with Existing Applications
Guide for integrating MiniKit into an existing Next.js project with installation, provider setup, and environment configuration
This guide helps developers integrate MiniKit into an existing Next.js project. It includes installation steps, provider setup and environment configuration.
This guide assumes you want to add MiniKit to an existing application. For new projects, use the MiniKit CLI for automatic setup.
Prerequisites
Before you begin, confirm the following:
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 MiniKitProvider
to initialise SDK context for your application.
File: providers/MiniKitProvider.tsx
Then wrap your app in app/layout.tsx
:
The provider automatically configures wagmi and react-query, and sets up connectors to use Farcaster when available.
Initialize MiniKit in your main page
Use the useMiniKit
hook to access the frame context and trigger readiness.
File: app/page.tsx
The 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.
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
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
These variables enhance your app’s appearance and metadata:
URL to your app’s icon (recommended: 48x48px PNG)
Brief subtitle shown in app listings
Detailed description of your app’s functionality
URL to splash screen image shown during app loading
Hex color code for splash screen background (e.g., “#000000”)
Primary category for app discovery (e.g., “social”, “gaming”, “utility”)
Hero image URL displayed in cast previews
Short, compelling tagline for your app
Open Graph title for social media sharing
Open Graph description for social media sharing
Open Graph image URL for social media previews
Don’t forget to include all referenced images in your public/
folder and ensure they’re accessible via HTTPS.
Generate the manifest
Use the OnchainKit CLI to generate account association credentials and update your environment variables.
Important: The wallet you connect must be your Farcaster custody wallet. You can import this wallet using the recovery phrase found in Warpcast under Settings → Advanced → Farcaster recovery phrase.
Follow these substeps:
- Connect your Farcaster custody wallet
- Add your deployed Vercel URL
- Sign the manifest to generate association credentials
- The CLI will automatically update your local
.env
file
After running this command locally, remember to update your deployment platform’s environment variables with the generated FARCASTER_HEADER
, FARCASTER_PAYLOAD
, and FARCASTER_SIGNATURE
values.
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.tsx
All image and API URLs used here must be publicly accessible via HTTPS. Test each URL in your browser before deploying.
Test and deploy your Mini App
Before sharing your Mini App, validate that everything is working correctly.
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.json
endpoint returns valid JSON - ✅ Your app loads without errors in a browser
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.json
endpoint returns valid JSON - ✅ Your app loads without errors in a browser
Use these tools to test your configuration:
Manifest Validator:
This tool validates:
- Manifest can be loaded successfully
- Frame metadata is correctly formatted
- Button actions and preview images are functioning
- Account association is properly configured
Manual Testing:
- Visit your deployed URL directly in a browser
- Check browser console for any errors
- Verify the MiniKit context loads properly
- Test frame readiness functionality
Once validation passes:
- Create a cast with your app’s URL in Warpcast
- Verify the preview displays your hero image and launch button
- Test the launch experience by clicking the button
- Share with others for feedback and testing
If your app doesn’t render as an embed, double-check your manifest configuration and ensure all URLs are publicly accessible.
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 shown
Function to call when your app is fully loaded and ready for interaction
You can use this context to personalize the experience, trigger different flows, or track user behavior.
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:
Test thoroughly
Share your Mini App URL in Warpcast and test all functionality with real users.
Monitor and iterate
Use analytics to understand how users interact with your app and identify areas for improvement.
Explore advanced features
Consider adding notifications, authentication, or other MiniKit hooks to enhance the user experience.