Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/components/FarcasterMiniApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { useEffect } from "react";
import { usePlatformDetection } from "../hooks/usePlatformDetection";

/**
* Calls `sdk.actions.ready()` to dismiss the splash screen — only in Farcaster clients.
* After Base App migration (April 2026), Base App operates as standard web app.
* Farcaster Mini App lifecycle — only runs in Farcaster clients.
*
* 1. Calls `sdk.actions.ready()` to dismiss the splash screen.
* 2. If the user hasn't added the app yet, triggers `sdk.actions.addMiniApp()`
* which shows the native Farcaster modal for install + notification permission.
* The SDK/client handles "already added" state — no re-prompting.
*
* Renders nothing — mount once near the root of the component tree.
*/
Expand All @@ -19,7 +23,20 @@ export function FarcasterMiniApp() {

import("@farcaster/miniapp-sdk").then(async ({ sdk }) => {
if (cancelled) return;

// Dismiss splash screen
sdk.actions.ready();

// Check if user has already added the miniapp
const context = await sdk.context;
if (cancelled || !context?.client) return;

if (!context.client.added) {
// Trigger native add/notification modal — SDK handles dismissal gracefully
sdk.actions.addMiniApp().catch(() => {
// User dismissed or SDK error — no action needed
});
}
}).catch(() => {
// Not in a Farcaster context — silently ignore
});
Expand Down
Loading