convert-farcaster-miniapp-to-app
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConvert Farcaster Miniapp to Base App
将Farcaster Miniapp转换为Base应用
Convert a Farcaster miniapp into a normal app on Base. The default outcome is a regular web app that works in the Base app browser and on the open web, with Farcaster Mini App host coupling removed.
If some Farcaster functionality truly needs to survive, keep it separate from the main app surface. Prefer read-only data first. Only preserve Mini App-specific behavior when the user explicitly insists, and isolate it behind a dedicated route or page rather than carrying it through the whole app.
将Farcaster miniapp转换为Base平台上的常规应用。默认输出是可在Base应用浏览器和开放Web中运行的常规Web应用,且移除了与Farcaster Mini App宿主的耦合。
如果某些Farcaster功能确实需要保留,请将其与主应用界面分离。优先保留只读数据。仅当用户明确要求时,才保留Mini App特定行为,并将其隔离在专用路由或页面中,而非贯穿整个应用。
Core Principle
核心原则
Always separate these decisions:
- Remove Mini App host/runtime coupling.
- Decide whether any Farcaster-facing functionality should remain.
- If something remains, keep it isolated from the main app and avoid introducing new vendor dependencies by default.
Do not automatically turn "keep some Farcaster functionality" into "migrate to Neynar." If a project already uses Neynar and the user wants to keep an isolated Farcaster-only area, you may preserve that existing integration. Do not introduce new Neynar adoption as the default recommendation.
始终分开以下决策:
- 移除Mini App宿主/运行时耦合。
- 决定是否保留任何面向Farcaster的功能。
- 若需保留部分功能,将其与主应用隔离,默认避免引入新的供应商依赖。
切勿自动将“保留部分Farcaster功能”等同于“迁移至Neynar”。如果项目已使用Neynar且用户希望保留独立的Farcaster专属区域,可保留现有集成。默认不推荐引入新的Neynar依赖。
Quick Start
快速开始
Follow these five phases sequentially:
- Discovery — Quick scan + quiz to choose a path
- Analysis — Detailed read-only analysis scoped to the chosen path
- Conversion — Remove Mini App SDK patterns and isolate any intentionally preserved Farcaster surface
- Cleanup — Remove dead code, env vars, and dependencies
- Verification — Type check, build, and summarize
按以下五个阶段依次执行:
- 发现阶段 — 快速扫描+问卷选择转换路径
- 分析阶段 — 根据所选路径进行详细的只读分析
- 转换阶段 — 移除Mini App SDK模式,隔离所有有意保留的Farcaster功能模块
- 清理阶段 — 移除死代码、环境变量和依赖项
- 验证阶段 — 类型检查、构建和总结
Conversion Paths
转换路径
The quiz should route the user into one of two paths:
| Path | Name | Who it's for | What happens |
|---|---|---|---|
| A | Regular App Default | Most projects | Strip Farcaster Mini App coupling and become a normal Base/web app |
| B | Isolated Farcaster Surface | The app still needs a small Farcaster-specific area | Convert the main app into a normal app, then keep only a separate Farcaster route/page for the remaining functionality |
Path B- Prefer read-only Farcaster data.
- Avoid preserving Mini App host/runtime behavior unless the user explicitly asks for it.
- Keep any preserved Farcaster logic out of the main app shell, shared providers, and primary auth flow.
问卷会引导用户进入以下两种路径之一:
| 路径 | 名称 | 适用对象 | 操作内容 |
|---|---|---|---|
| A | 默认常规应用 | 大多数项目 | 移除Farcaster Mini App耦合,成为常规Base/Web应用 |
| B | 隔离式Farcaster功能模块 | 仍需保留少量Farcaster特定功能的应用 | 将主应用转换为常规应用,仅保留一个独立的Farcaster路由/页面用于剩余功能 |
路径B- 优先保留只读Farcaster数据。
- 除非用户明确要求,否则避免保留Mini App宿主/运行时行为。
- 将所有保留的Farcaster逻辑排除在主应用外壳、共享提供者和主要认证流程之外。
Phase 0: Discovery
阶段0:发现
0A. Quick Scan (automated, no user interaction)
0A. 快速扫描(自动化,无需用户交互)
Run a lightweight scan before asking questions. Produce an internal tally:
- Detect framework from (
package.json,next,vite,react-scripts)@remix-run/* - Count Farcaster packages in and
dependenciesdevDependencies - Grep source files (,
.ts,.tsx,.js) for:.jsx- calls (count total)
sdk.actions.* - usage (yes/no)
sdk.quickAuth - usage (yes/no)
sdk.context - (yes/no)
.well-known/farcaster.json - /
farcasterMiniAppconnector (yes/no)miniAppConnector - Total files with any import
@farcaster/ - imports or
@neynar/fetch calls (yes/no)api.neynar.com
- Identify the blast radius:
- Are Farcaster references spread across the main app shell?
- Are they already mostly confined to a route like ,
app/farcaster/, or a small set of components?pages/farcaster/ - Are there obvious host-only features such as haptics, notifications, , or
openMiniApp?sdk.context.client
Use this tally to inform quiz suggestions. Do not dump raw scan output to the user before asking the quiz.
在提问前先执行轻量扫描,生成内部统计结果:
- 从中检测框架(
package.json、next、vite、react-scripts)@remix-run/* - 统计和
dependencies中的Farcaster包数量devDependencies - 在源文件(、
.ts、.tsx、.js)中搜索:.jsx- 调用(统计总数)
sdk.actions.* - 使用情况(是/否)
sdk.quickAuth - 使用情况(是/否)
sdk.context - (是/否)
.well-known/farcaster.json - /
farcasterMiniApp连接器(是/否)miniAppConnector - 包含导入的文件总数
@farcaster/ - 导入或
@neynar/请求调用(是/否)api.neynar.com
- 确定影响范围:
- Farcaster引用是否遍布主应用外壳?
- 它们是否已大多局限于、
app/farcaster/等路由或少量组件中?pages/farcaster/ - 是否存在明显的宿主专属功能,如触觉反馈、通知、或
openMiniApp?sdk.context.client
使用这些统计结果为问卷提供建议。在提问前,不要向用户输出原始扫描结果。
0B. Interactive Quiz
0B. 交互式问卷
Ask these questions one at a time. Use the quick scan results to suggest the most likely answer.
Q1 (always ask):
Based on my scan, your project has [X] files using the Farcaster SDK with [summary of what is used].Which outcome do you want?
- (a) Regular app everywhere — remove Farcaster-specific behavior and just keep a normal Base/web app
- (b) Regular app first, plus a separate Farcaster area — keep the main app clean, but preserve a small isolated route/page if really needed
Q2 (always ask):
How deeply is the Mini App SDK used today?
- (a) Minimal — mostly
and a few helperssdk.actions.ready()- (b) Moderate — some
,context, profile links, or conditionalopenUrllogicisInMiniApp- (c) Heavy — auth, wallet connector, notifications, compose flows, or host-specific behavior
Q3 (ask if Q1 = b):
What is the smallest Farcaster feature set you actually need to preserve?
- (a) Read-only only — profile or cast display, links out to Farcaster profiles, maybe a small social page
- (b) Some Farcaster-specific interactions — there is a separate page/path that still needs more than read-only behavior
- (c) Not sure — analyze what is isolated already and recommend the smallest keep-surface possible
Q4 (ask if Q1 = b and there is existing isolated Farcaster code or existing Neynar usage):
Does the project already have an isolated Farcaster-only route/page or integration that you want to keep as-is if possible?
- (a) Yes — preserve only that isolated surface
- (b) No — prefer removing it unless there is a very strong reason to keep it
Q5 (ask if quick auth or other Mini App auth is present):
After conversion, what should the main app use for authentication?
- (a) SIWE — wallet-based auth for the regular app
- (b) Existing non-Farcaster auth — keep whatever normal web auth already exists
- (c) No auth — remove auth entirely
依次提出以下问题。利用快速扫描结果给出最可能的答案建议。
问题1(必问):
根据扫描结果,你的项目中有[X]个文件使用Farcaster SDK,涉及[功能摘要]。你希望得到哪种结果?
- (a) 全平台常规应用 — 移除Farcaster特定行为,仅保留常规Base/Web应用
- (b) 主应用为常规应用,外加独立Farcaster区域 — 保持主应用简洁,仅在确实需要时保留一个小型隔离路由/页面
问题2(必问):
当前Mini App SDK的使用深度如何?
- (a) 轻度 — 主要使用
和少量辅助函数sdk.actions.ready()- (b) 中度 — 使用部分
、context、个人资料链接或条件openUrl逻辑isInMiniApp- (c) 重度 — 使用认证、钱包连接器、通知、发布流程或宿主特定行为
问题3(仅当问题1选b时提问):
你实际需要保留的最小Farcaster功能集是什么?
- (a) 仅只读功能 — 个人资料或动态展示、指向Farcaster个人资料的链接,可能包含小型社交页面
- (b) 部分Farcaster特定交互 — 存在某个单独页面/路径仍需要超出只读的功能
- (c) 不确定 — 分析当前已隔离的功能,建议保留最小必要的功能模块
问题4(仅当问题1选b且项目已有隔离的Farcaster代码或Neynar使用时提问):
项目中是否已有一个隔离的Farcaster专属路由/页面或集成,你希望尽可能原样保留?
- (a) 是 — 仅保留该隔离功能模块
- (b) 否 — 优先移除,除非有非常充分的保留理由
问题5(仅当存在快速认证或其他Mini App认证时提问):
转换后,主应用应使用哪种认证方式?
- (a) SIWE — 基于钱包的常规应用认证
- (b) 现有非Farcaster认证 — 保留已有的常规Web认证方式
- (c) 无认证 — 完全移除认证
0C. Path Selection
0C. 路径选择
Map answers to a path:
| Desired outcome | Typical result |
|---|---|
| Path A — Regular App Default |
| Path B — Isolated Farcaster Surface |
Then tighten the recommendation:
- If the user chose , prefer read-only preservation unless they explicitly require something else.
Path B - If the scan shows heavy host/runtime coupling but the user wants , warn them that some features will be deleted rather than recreated.
Path A - If the project already uses Neynar, only keep it if it remains inside the isolated Farcaster surface. Do not expand it into the main app.
Announce the chosen path:
Based on your answers, I'll use Path [X]: [Name]. This will [one-sentence description]. I'll now do a detailed analysis of your project.
Record the quiz answers internally. They guide whether the agent should:
- fully remove Farcaster features
- preserve only a read-only isolated surface
- quarantine any unavoidable Farcaster-specific logic to a dedicated route/page
Proceed to Phase 1.
将答案映射到对应路径:
| 期望结果 | 典型输出 |
|---|---|
| 路径A — 默认常规应用 |
| 路径B — 隔离式Farcaster功能模块 |
然后细化建议:
- 如果用户选择,优先采用只读保留,除非用户明确要求其他方式。
路径B - 如果扫描显示存在重度宿主/运行时耦合,但用户选择,需警告用户部分功能将被删除而非重构。
路径A - 如果项目已使用Neynar,仅当它保留在隔离的Farcaster功能模块内时才保留,不要将其扩展到主应用中。
告知用户所选路径:
根据你的回答,我将使用路径[X]:[名称]。该路径会[一句话描述]。现在我将对你的项目进行详细分析。
内部记录问卷答案,指导代理是否:
- 完全移除Farcaster功能
- 仅保留只读的隔离功能模块
- 将任何不可避免的Farcaster特定逻辑隔离到专用路由/页面
进入阶段1。
Phase 1: Analysis (Read-Only)
阶段1:分析(只读)
1A. Detect Framework
1A. 检测框架
Read :
package.json- → Next.js
next - → Vite
vite - → Create React App
react-scripts - → Remix
@remix-run/*
读取:
package.json- → Next.js
next - → Vite
vite - → Create React App
react-scripts - → Remix
@remix-run/*
1B. Scan for Farcaster Dependencies
1B. 扫描Farcaster依赖项
List all packages matching:
- ,
@farcaster/miniapp-sdk,@farcaster/miniapp-core@farcaster/miniapp-wagmi-connector - ,
@farcaster/frame-sdk@farcaster/frame-wagmi-connector - ,
@farcaster/quick-auth@farcaster/auth-kit - (compatibility only; do not assume it stays)
@neynar/*
列出所有匹配的包:
- 、
@farcaster/miniapp-sdk、@farcaster/miniapp-core@farcaster/miniapp-wagmi-connector - 、
@farcaster/frame-sdk@farcaster/frame-wagmi-connector - 、
@farcaster/quick-auth@farcaster/auth-kit - (仅兼容;不默认保留)
@neynar/*
1C. Grep for Farcaster Code
1C. 搜索Farcaster代码
Search source files (, , , ) for:
.ts.tsx.js.jsxSDK imports:
@farcaster/miniapp-sdk
@farcaster/miniapp-core
@farcaster/miniapp-wagmi-connector
@farcaster/frame-sdk
@farcaster/frame-wagmi-connector
@farcaster/quick-auth
@farcaster/auth-kit
@neynar/SDK calls:
sdk.actions.ready
sdk.actions.openUrl
sdk.actions.close
sdk.actions.composeCast
sdk.actions.addMiniApp
sdk.actions.requestWalletAddress
sdk.actions.viewProfile
sdk.actions.viewToken
sdk.actions.sendToken
sdk.actions.swapToken
sdk.actions.signIn
sdk.actions.setPrimaryButton
sdk.actions.openMiniApp
sdk.quickAuth
sdk.context
sdk.isInMiniApp
sdk.getCapabilities
sdk.haptics
sdk.back
sdk.walletConnectors & providers:
farcasterMiniApp()
miniAppConnector()
farcasterFrame()
MiniAppProvider
MiniAppContext
useMiniApp
useMiniAppContextManifest & meta:
.well-known/farcaster.json
fc:miniapp
fc:frameEnvironment variables:
NEYNAR_API_KEY
NEXT_PUBLIC_NEYNAR_CLIENT_ID
FARCASTER_
FC_在源文件(、、、)中搜索:
.ts.tsx.js.jsxSDK导入:
@farcaster/miniapp-sdk
@farcaster/miniapp-core
@farcaster/miniapp-wagmi-connector
@farcaster/frame-sdk
@farcaster/frame-wagmi-connector
@farcaster/quick-auth
@farcaster/auth-kit
@neynar/SDK调用:
sdk.actions.ready
sdk.actions.openUrl
sdk.actions.close
sdk.actions.composeCast
sdk.actions.addMiniApp
sdk.actions.requestWalletAddress
sdk.actions.viewProfile
sdk.actions.viewToken
sdk.actions.sendToken
sdk.actions.swapToken
sdk.actions.signIn
sdk.actions.setPrimaryButton
sdk.actions.openMiniApp
sdk.quickAuth
sdk.context
sdk.isInMiniApp
sdk.getCapabilities
sdk.haptics
sdk.back
sdk.wallet连接器与提供者:
farcasterMiniApp()
miniAppConnector()
farcasterFrame()
MiniAppProvider
MiniAppContext
useMiniApp
useMiniAppContext清单与元数据:
.well-known/farcaster.json
fc:miniapp
fc:frame环境变量:
NEYNAR_API_KEY
NEXT_PUBLIC_NEYNAR_CLIENT_ID
FARCASTER_
FC_1D. Check Existing Web3 Setup
1D. 检查现有Web3配置
Look for:
- connector in wagmi config
coinbaseWallet - SIWE / package usage
siwe - ,
connectkit, orrainbowkit@coinbase/onchainkit - Existing wallet connection UI
查找:
- wagmi配置中的连接器
coinbaseWallet - SIWE / 包的使用情况
siwe - 、
connectkit或rainbowkit@coinbase/onchainkit - 现有钱包连接UI
1E. Check Separation Boundaries
1E. 检查分离边界
Map where Farcaster logic currently lives:
- Root providers or app shell
- Shared hooks or auth middleware
- One-off components
- Dedicated routes/pages like
app/farcaster/* - Server routes used only by Farcaster functionality
Mark each location with one action:
- remove
- stub
- move behind isolated route/page
- keep only as read-only
映射Farcaster逻辑当前的存放位置:
- 根提供者或应用外壳
- 共享钩子或认证中间件
- 独立组件
- 专用路由/页面,如
app/farcaster/* - 仅用于Farcaster功能的服务端路由
为每个位置标记操作类型:
- 移除
- 存根
- 移至隔离路由/页面后
- 仅保留只读功能
1F. Report Findings
1F. 报告分析结果
Create a path-scoped summary.
All paths include:
undefined创建路径专属的摘要。
所有路径均包含:
undefinedConversion Analysis — Path [X]: [Name]
转换分析 — 路径[X]:[名称]
Framework: [detected]
Farcaster packages: [list]
Files with Farcaster code: [count]
框架: [检测结果]
Farcaster包: [列表]
包含Farcaster代码的文件数: [数量]
Wagmi Connector
Wagmi连接器
- File: [path]
- Current connector: [farcasterMiniApp / miniAppConnector / farcasterFrame / none]
- Other connectors: [list]
- Action: [replace with coinbaseWallet / leave existing wallet setup / remove only]
- 文件:[路径]
- 当前连接器:[farcasterMiniApp / miniAppConnector / farcasterFrame / 无]
- 其他连接器:[列表]
- 操作:[替换为coinbaseWallet / 保留现有钱包配置 / 仅移除]
MiniApp Provider
MiniApp提供者
- File: [path]
- Pattern: [simple / complex]
- Consumers: [files importing from this]
- Action: [stub / remove / isolate]
- 文件:[路径]
- 模式:[简单 / 复杂]
- 使用者:[导入该文件的文件列表]
- 操作:[存根 / 移除 / 隔离]
SDK Action Calls
SDK操作调用
[list each: file, what it does, action]
[列出每个调用:文件、功能、操作]
Manifest & Meta
清单与元数据
- Manifest route: [path or N/A]
- Meta tags: [file or N/A]
**Path A additionally includes:**- 清单路由:[路径或无]
- 元标签:[文件或无]
**路径A额外包含:**Main App Outcome
主应用输出
- Action: remove Farcaster-specific UI and flows from the main app entirely
- 操作:从主应用中完全移除Farcaster特定UI和流程
Authentication
认证
- Quick Auth used: [yes/no, file]
- Action: replace with SIWE / keep existing non-Farcaster auth / remove
- 使用快速认证:[是/否,文件路径]
- 操作:替换为SIWE / 保留现有非Farcaster认证 / 移除
Existing Neynar Usage
现有Neynar使用情况
- Package or files: [list or N/A]
- Action: remove entirely unless the user later re-scopes to Path B
- 包或文件:[列表或无]
- 操作:完全移除,除非用户后续重新选择路径B
Environment Variables
环境变量
[list all FC/Neynar vars that will be removed]
**Path B additionally includes:**[列出所有将被移除的FC/Neynar变量]
**路径B额外包含:**Main App Outcome
主应用输出
- Action: convert the main app into a normal web app first
- 操作:先将主应用转换为常规Web应用
Isolated Farcaster Surface
隔离式Farcaster功能模块
- Route/page to keep: [path or proposed path]
- Scope: [read-only / mixed / host-specific]
- Recommended target scope: [prefer read-only / quarantine existing behavior / remove]
- 保留的路由/页面:[路径或建议路径]
- 范围:[只读 / 混合 / 宿主特定]
- 建议目标范围:[优先只读 / 隔离现有行为 / 移除]
Authentication
认证
- Quick Auth used: [yes/no, file]
- Main app action: replace with SIWE / keep existing non-Farcaster auth / remove
- Isolated Farcaster surface action: [remove auth coupling / preserve existing isolated flow only if explicitly requested]
- 使用快速认证:[是/否,文件路径]
- 主应用操作:替换为SIWE / 保留现有非Farcaster认证 / 移除
- 隔离Farcaster功能模块操作:[移除认证耦合 / 仅在用户明确要求时保留现有隔离流程]
Existing Neynar Usage
现有Neynar使用情况
- Package or files: [list or N/A]
- Action: [remove / keep only inside isolated surface]
- 包或文件:[列表或无]
- 操作:[移除 / 仅在隔离功能模块内保留]
Environment Variables
环境变量
- Remove from main app: [FC_, FARCASTER_, etc.]
- Keep only if isolated surface truly still needs them: [NEYNAR_API_KEY, etc. or N/A]
**All paths end with:**- 从主应用中移除:[FC_, FARCASTER_, 等]
- 仅当隔离功能模块确实仍需时保留:[NEYNAR_API_KEY, 等或无]
**所有路径均以以下内容结尾:**Potential Issues
潜在问题
- FID used as database primary key
- Farcaster colors in tailwind config
- branches with unique else logic
isInMiniApp - Components only meaningful inside Farcaster
- Farcaster code mixed into shared providers or root layout
Ask:
> Does this analysis look correct? Ready to proceed with conversion?
**STOP and wait for user confirmation before Phase 2.**
---- FID被用作数据库主键
- tailwind配置中包含Farcaster品牌颜色
- 分支包含唯一的else逻辑
isInMiniApp - 仅在Farcaster内有意义的组件
- Farcaster代码混入共享提供者或根布局
询问用户:
> 该分析是否正确?是否准备开始转换?
**在进入阶段2前,停止并等待用户确认。**
---Phase 2: Conversion
阶段2:转换
Steps are organized by feature area. Each step notes which paths it applies to and what to do differently for .
Path B步骤按功能区域组织。每个步骤会注明适用路径以及的特殊处理方式。
路径B2A. Wagmi Connector (All Paths)
2A. Wagmi连接器(所有路径)
Find the wagmi config file (, , , etc.):
lib/wagmi.tsconfig/wagmi.tsproviders/wagmi-provider.tsx- Remove import of or
farcasterMiniAppfromminiAppConnector@farcaster/miniapp-wagmi-connector - Remove the /
farcasterMiniApp()call from theminiAppConnector()arrayconnectors - If no wallet connector remains, add:
typescript
import { coinbaseWallet } from "wagmi/connectors"; coinbaseWallet({ appName: "<app name>" }) - If already exists, leave it as-is
coinbaseWallet - Clean up empty lines and stale imports
Skip this step if wagmi is not in the project.
找到wagmi配置文件(、、等):
lib/wagmi.tsconfig/wagmi.tsproviders/wagmi-provider.tsx- 移除从导入的
@farcaster/miniapp-wagmi-connector或farcasterMiniAppminiAppConnector - 从数组中移除
connectors/farcasterMiniApp()调用miniAppConnector() - 如果没有剩余钱包连接器,添加:
typescript
import { coinbaseWallet } from "wagmi/connectors"; coinbaseWallet({ appName:"<应用名称>" }) - 如果已存在,保持原样
coinbaseWallet - 清理空行和过期导入
如果项目中没有wagmi,跳过此步骤。
2B. MiniApp Provider / Context (All Paths)
2B. MiniApp提供者 / 上下文(所有路径)
If the app has a shared Mini App provider, remove host/runtime assumptions from the main app.
Pattern A: simple provider
Replace with a safe stub:
tsx
'use client'
import React, { createContext, useContext, useMemo } from "react";
interface MiniAppContextType {
context: undefined;
ready: boolean;
isInMiniApp: boolean;
}
const MiniAppContext = createContext<MiniAppContextType | undefined>(undefined);
export function useMiniAppContext() {
const context = useContext(MiniAppContext);
if (context === undefined) {
throw new Error("useMiniAppContext must be used within a MiniAppProvider");
}
return context;
}
export default function MiniAppProvider({ children }: { children: React.ReactNode }) {
const value = useMemo(
() => ({
context: undefined,
ready: true,
isInMiniApp: false,
}),
[]
);
return <MiniAppContext.Provider value={value}>{children}</MiniAppContext.Provider>;
}Preserve export style and hook names so consumers do not break.
Pattern B: complex provider
- If many consumers depend on it, stub it first.
- If only a few files use it, remove it and update those imports directly.
- In , do not let the isolated Farcaster surface keep this provider wired through the root app shell. If needed, make it local to the isolated route only.
Path B
如果应用有共享Mini App提供者,从主应用中移除宿主/运行时假设。
模式A:简单提供者
替换为安全的存根:
tsx
'use client'
import React, { createContext, useContext, useMemo } from "react";
interface MiniAppContextType {
context: undefined;
ready: boolean;
isInMiniApp: boolean;
}
const MiniAppContext = createContext<MiniAppContextType | undefined>(undefined);
export function useMiniAppContext() {
const context = useContext(MiniAppContext);
if (context === undefined) {
throw new Error("useMiniAppContext必须在MiniAppProvider内使用");
}
return context;
}
export default function MiniAppProvider({ children }: { children: React.ReactNode }) {
const value = useMemo(
() => ({
context: undefined,
ready: true,
isInMiniApp: false,
}),
[]
);
return <MiniAppContext.Provider value={value}>{children}</MiniAppContext.Provider>;
}保留导出样式和钩子名称,避免使用者代码报错。
模式B:复杂提供者
- 如果有大量使用者依赖,先创建存根。
- 如果只有少量文件使用,直接移除并更新这些文件的导入。
- 在中,不要让隔离的Farcaster功能模块通过根应用外壳保留该提供者。如果需要,仅在隔离路由内本地化使用。
路径B
2C. Authentication
2C. 认证
The main app should use normal web auth, not Mini App auth.
Default rule for both paths:
- If is used, replace it with SIWE or remove it.
sdk.quickAuth.getToken() - If a normal non-Farcaster auth system already exists, prefer that over adding new auth.
- Do not introduce new Farcaster or Neynar auth as the default conversion target.
主应用应使用常规Web认证,而非Mini App认证。
适用于所有路径的默认规则:
- 如果使用,替换为SIWE或移除。
sdk.quickAuth.getToken() - 如果已有常规非Farcaster认证系统,优先使用现有系统而非添加新认证。
- 默认转换目标不引入新的Farcaster或Neynar认证。
SIWE Replacement Pattern
SIWE替换模式
Client-side (e.g. ):
useSignIn.ts- Remove
import sdk from "@farcaster/miniapp-sdk" - Remove
sdk.quickAuth.getToken() - Replace with:
- Get wallet address from (wagmi)
useAccount() - Create a SIWE message with
siwe - Sign with (wagmi)
useSignMessage() - Send signature + message to the backend for verification
- Get wallet address from
Server-side (e.g. ):
app/api/auth/sign-in/route.ts- Remove verification
@farcaster/quick-auth - Replace with SIWE verification:
- Parse the SIWE message
- Verify the signature with or
siweviem - Use recovered wallet address as the normal app identity
If FID is used as a database primary key:
- Do not auto-change schema
- Add a TODO comment for later migration
- Warn in Phase 4 summary
Path B note:
- If the isolated Farcaster surface already has its own auth or integration flow and the user explicitly wants to keep it, quarantine it there only.
- Do not let that flow remain the default app-wide auth system.
客户端(例如):
useSignIn.ts- 移除
import sdk from "@farcaster/miniapp-sdk" - 移除
sdk.quickAuth.getToken() - 替换为:
- 从(wagmi)获取钱包地址
useAccount() - 使用创建SIWE消息
siwe - 使用(wagmi)签名
useSignMessage() - 将签名+消息发送到后端进行验证
- 从
服务端(例如):
app/api/auth/sign-in/route.ts- 移除验证
@farcaster/quick-auth - 替换为SIWE验证:
- 解析SIWE消息
- 使用或
siwe验证签名viem - 使用恢复的钱包地址作为常规应用身份
如果FID被用作数据库主键:
- 不要自动更改数据库 schema
- 添加TODO注释以便后续迁移
- 在阶段4的总结中发出警告
路径B注意事项:
- 如果隔离的Farcaster功能模块已有自己的认证或集成流程,且用户明确要求保留,仅在该模块内隔离保留。
- 不要让该流程成为应用级的默认认证系统。
2D. SDK Action Calls
2D. SDK操作调用
2D-1. Main replacements for both paths
2D-1. 适用于所有路径的主要替换规则
| Original | Replacement |
|---|---|
| Remove entirely |
| |
| |
| Remove from the main app |
| Remove call and UI |
| Remove; wagmi handles wallet access |
| |
| |
| Replace with wagmi flow if the feature matters, otherwise remove |
| Remove call and UI unless there is a real app-specific swap feature outside Farcaster |
| Remove; auth handled by normal web auth |
| Remove entirely |
| Remove from the main app |
| Remove conditional and keep the non-Farcaster branch |
| Remove from the main app |
| Remove or replace with |
| Remove entirely |
| Remove entirely |
| Remove; wagmi handles wallet access |
For conditional branches:
isInMiniApptsx
// BEFORE
if (isInMiniApp) {
sdk.actions.openUrl(url);
} else {
window.open(url, "_blank");
}
// AFTER
window.open(url, "_blank");Always keep the normal web branch.
| 原调用 | 替换内容 |
|---|---|
| 完全移除 |
| |
| |
| 从主应用中移除 |
| 移除调用和UI |
| 移除;wagmi处理钱包访问 |
| |
| |
| 如果该功能重要,替换为wagmi流程;否则移除 |
| 移除调用和UI,除非Farcaster之外有真正的应用专属兑换功能 |
| 移除;由常规Web认证处理 |
| 完全移除 |
| 从主应用中移除 |
| 移除条件判断,保留常规Web分支 |
| 从主应用中移除 |
| 移除或替换为 |
| 完全移除 |
| 完全移除 |
| 移除;wagmi处理钱包访问 |
对于条件分支:
isInMiniApptsx
// 转换前
if (isInMiniApp) {
sdk.actions.openUrl(url);
} else {
window.open(url, "_blank");
}
// 转换后
window.open(url, "_blank");始终保留常规Web分支。
2D-2. Path B overrides
2D-2. 路径B的特殊处理
Path B-
sdk.context- Remove from the main app
- For the isolated surface, prefer replacing it with read-only fetched data or explicit route params
- Remove ,
context.location, safe area, and other host-derived assumptions unless the user explicitly insists on preserving a host-specific pagecontext.client
-
sdk.actions.composeCast(...)- Remove from the main app
- If the user only needs read-only, delete it entirely
- If they insist on preserving it, keep it isolated behind a dedicated page/path and flag it as a manual follow-up rather than rebuilding it by default
-
sdk.actions.openMiniApp(...)- Remove from the main app
- Only keep it in an isolated route if the user explicitly wants a Farcaster-only surface
-
notifications / haptics / host buttons
- Remove from the main app
- Preserve only if the isolated route truly depends on them and the user has explicitly opted into that complexity
路径B-
sdk.context- 从主应用中移除
- 对于隔离功能模块,优先替换为只读获取的数据或显式路由参数
- 移除、
context.location、安全区域和其他宿主派生的假设,除非用户明确要求保留宿主特定页面context.client
-
sdk.actions.composeCast(...)- 从主应用中移除
- 如果用户仅需要只读功能,完全删除
- 如果用户坚持保留,将其隔离在专用页面/路径后,并标记为手动后续任务,而非默认重建
-
sdk.actions.openMiniApp(...)- 从主应用中移除
- 仅当用户明确需要Farcaster专属功能模块时,才在隔离路由中保留
-
通知 / 触觉反馈 / 宿主按钮
- 从主应用中移除
- 仅当隔离路由确实依赖且用户明确选择该复杂度时才保留
2E. Optional Read-Only Farcaster Data (Path B only)
2E. 可选只读Farcaster数据(仅路径B)
If the user wants an isolated Farcaster surface, prefer read-only data first.
Create (or equivalent) only if the app needs it:
lib/farcaster-readonly.tstypescript
const HUB_URL = "https://hub.farcaster.xyz";
export async function getUserData(fid: number) {
const res = await fetch(`${HUB_URL}/v1/userDataByFid?fid=${fid}`);
if (!res.ok) throw new Error(`Hub user data fetch failed: ${res.status}`);
return res.json();
}
export async function getCastsByFid(fid: number, pageSize = 25) {
const res = await fetch(`${HUB_URL}/v1/castsByFid?fid=${fid}&pageSize=${pageSize}`);
if (!res.ok) throw new Error(`Hub casts fetch failed: ${res.status}`);
return res.json();
}Then:
- Keep these calls inside the isolated route/page only
- Do not thread Farcaster data requirements through the main app shell
- If the project already has a small isolated Neynar-based read-only integration, you may keep it only if removing it would create more churn than it saves
- Do not add new Neynar packages for this by default
如果用户需要隔离的Farcaster功能模块,优先保留只读数据。
仅当应用需要时,创建(或等效文件):
lib/farcaster-readonly.tstypescript
const HUB_URL = "https://hub.farcaster.xyz";
export async function getUserData(fid: number) {
const res = await fetch(`${HUB_URL}/v1/userDataByFid?fid=${fid}`);
if (!res.ok) throw new Error(`Hub用户数据获取失败: ${res.status}`);
return res.json();
}
export async function getCastsByFid(fid: number, pageSize = 25) {
const res = await fetch(`${HUB_URL}/v1/castsByFid?fid=${fid}&pageSize=${pageSize}`);
if (!res.ok) throw new Error(`Hub动态获取失败: ${res.status}`);
return res.json();
}然后:
- 仅在隔离路由/页面内保留这些调用
- 不要让Farcaster数据需求贯穿主应用外壳
- 如果项目已有小型隔离的基于Neynar的只读集成,若移除会导致更多混乱,可保留
- 默认不添加新的Neynar包
2F. Manifest Route (All Paths)
2F. 清单路由(所有路径)
Delete route:
.well-known/farcaster.jsonapp/.well-known/farcaster.json/route.tspublic/.well-known/farcaster.json- or similar helpers
api/farcaster-manifest.ts
If the directory becomes empty, delete it.
.well-known删除路由:
.well-known/farcaster.jsonapp/.well-known/farcaster.json/route.tspublic/.well-known/farcaster.json- 或类似辅助文件
api/farcaster-manifest.ts
如果目录变空,删除该目录。
.well-known2G. Meta Tags (All Paths)
2G. 元标签(所有路径)
In root layout or metadata files, remove:
- tags with
<meta>orproperty="fc:miniapp*"property="fc:frame*" - entries that only exist for Farcaster tags
Metadata.other - logic that only produces Mini App metadata
generateMetadata
在根布局或元数据文件中移除:
- 属性为或
property="fc:miniapp*"的property="fc:frame*"标签<meta> - 仅为Farcaster标签存在的条目
Metadata.other - 仅生成Mini App元数据的逻辑
generateMetadata
2H. Dependencies
2H. 依赖项
All paths — remove:
- ,
@farcaster/miniapp-sdk,@farcaster/miniapp-wagmi-connector@farcaster/miniapp-core - ,
@farcaster/frame-sdk@farcaster/frame-wagmi-connector - ,
@farcaster/quick-auth@farcaster/auth-kit
Path A — also remove:
- ,
@neynar/nodejs-sdk@neynar/react - any other Neynar packages or helpers
Path B — remove by default:
- ,
@neynar/nodejs-sdk, and Neynar helpers unless they remain inside the intentionally isolated Farcaster surface@neynar/react
All paths — add only if truly needed:
- if SIWE auth is introduced and not already present
siwe
Do not add new Neynar packages as part of the default conversion.
所有路径 — 移除:
- 、
@farcaster/miniapp-sdk、@farcaster/miniapp-wagmi-connector@farcaster/miniapp-core - 、
@farcaster/frame-sdk@farcaster/frame-wagmi-connector - 、
@farcaster/quick-auth@farcaster/auth-kit
路径A — 额外移除:
- 、
@neynar/nodejs-sdk@neynar/react - 任何其他Neynar包或辅助工具
路径B — 默认移除:
- 、
@neynar/nodejs-sdk和Neynar辅助工具,除非它们仍在有意隔离的Farcaster功能模块内@neynar/react
所有路径 — 仅在确实需要时添加:
- 若引入SIWE认证,添加
siwe
默认不添加新的Neynar包作为转换的一部分。
2I. Farcaster-Specific Routes & Components
2I. Farcaster特定路由与组件
Path A:
- Delete ,
app/farcaster/, and Farcaster-only components entirelypages/farcaster/ - Delete Farcaster-only API routes such as and
/api/farcaster/*/api/neynar/* - Remove any navigation links that point to deleted routes
Path B:
- Keep the main app route tree clean
- Move preserved Farcaster UI behind one dedicated route/page if it is not already isolated
- Prefer names like or
app/farcaster/over spreading Farcaster logic throughout generic shared pagesapp/social/ - Remove any component that has no purpose outside that isolated surface
- Keep any remaining Neynar usage, if any, confined to that isolated route/page and its server helpers only
路径A:
- 完全删除、
app/farcaster/和Farcaster专属组件pages/farcaster/ - 删除Farcaster专属API路由,如和
/api/farcaster/*/api/neynar/* - 移除指向已删除路由的所有导航链接
路径B:
- 保持主应用路由树整洁
- 若未隔离,将保留的Farcaster UI移至一个专用路由/页面后
- 优先使用或
app/farcaster/等名称,避免将Farcaster逻辑分散到通用共享页面app/social/ - 移除所有在隔离功能模块外无意义的组件
- 若保留Neynar使用,仅将其限制在该隔离路由/页面及其服务端辅助工具内
Phase 3: Cleanup
阶段3:清理
3A. Update package.json
package.json3A. 更新package.json
package.jsonAll paths — remove Mini App packages:
- ,
@farcaster/miniapp-sdk,@farcaster/miniapp-wagmi-connector@farcaster/miniapp-core - ,
@farcaster/frame-sdk@farcaster/frame-wagmi-connector - ,
@farcaster/quick-auth@farcaster/auth-kit
Path A — also remove:
- all packages
@neynar/*
Path B — remove unless still isolated and intentionally preserved:
@neynar/*
All paths — add if introduced:
siwe
所有路径 — 移除Mini App包:
- 、
@farcaster/miniapp-sdk、@farcaster/miniapp-wagmi-connector@farcaster/miniapp-core - 、
@farcaster/frame-sdk@farcaster/frame-wagmi-connector - 、
@farcaster/quick-auth@farcaster/auth-kit
路径A — 额外移除:
- 所有包
@neynar/*
路径B — 移除,除非仍在隔离且有意保留:
@neynar/*
所有路径 — 若引入则添加:
siwe
3B. Environment Variables
3B. 环境变量
Path A — remove from all files:
.env*NEYNAR_API_KEYNEXT_PUBLIC_NEYNAR_CLIENT_IDFARCASTER_*FC_*NEXT_PUBLIC_FC_*NEXT_PUBLIC_FARCASTER_*
Path B — remove from the main app by default:
FARCASTER_*FC_*NEXT_PUBLIC_FC_*NEXT_PUBLIC_FARCASTER_*
Only keep vars if the isolated surface explicitly still depends on existing Neynar integration.
NEYNAR_*Also update env validation schemas (, , zod schemas, etc.).
env.tsenv.mjs路径A — 从所有文件中移除:
.env*NEYNAR_API_KEYNEXT_PUBLIC_NEYNAR_CLIENT_IDFARCASTER_*FC_*NEXT_PUBLIC_FC_*NEXT_PUBLIC_FARCASTER_*
路径B — 默认从主应用中移除:
FARCASTER_*FC_*NEXT_PUBLIC_FC_*NEXT_PUBLIC_FARCASTER_*
仅当隔离功能模块明确仍依赖现有Neynar集成时,才保留变量。
NEYNAR_*同时更新环境变量验证 schema(、、zod schema等)。
env.tsenv.mjs3C. Dead Code Cleanup
3C. 死代码清理
- Remove unused imports from modified files
- Remove unused Farcaster types and helper functions
- Remove empty import statements
- Remove dead hooks or API wrappers that only existed for the Mini App SDK
- 从修改的文件中移除未使用的导入
- 移除未使用的Farcaster类型和辅助函数
- 移除空导入语句
- 移除仅为Mini App SDK存在的死钩子或API包装器
3D. Tailwind Colors
3D. Tailwind颜色
If or includes Farcaster brand colors such as , remove them unless that branding is intentionally kept inside an isolated Farcaster-only surface.
tailwind.config.tstailwind.config.jsfarcaster: "#8B5CF6"如果或包含Farcaster品牌颜色,如,除非该品牌颜色有意保留在隔离的Farcaster专属功能模块内,否则将其移除。
tailwind.config.tstailwind.config.jsfarcaster: "#8B5CF6"3E. Install Dependencies
3E. 安装依赖项
Tell the user:
bash
npm install告知用户执行:
bash
npm installPhase 4: Verification
阶段4:验证
4A. Search for Remaining References
4A. 搜索剩余引用
All paths — search for:
@farcaster
farcasterMiniApp
miniAppConnector
sdk.actions
sdk.quickAuth
sdk.context
fc:miniapp
fc:framePath A — also search for:
@neynar
NEYNAR_API_KEY
NEXT_PUBLIC_NEYNAR_CLIENT_ID
api.neynar.comPath B — if Neynar was intentionally preserved:
- verify that remaining imports and env vars exist only inside the isolated Farcaster surface and its server helpers
@neynar
Report any source matches, ignoring , lock files, and git history.
node_modules所有路径 — 搜索:
@farcaster
farcasterMiniApp
miniAppConnector
sdk.actions
sdk.quickAuth
sdk.context
fc:miniapp
fc:frame路径A — 额外搜索:
@neynar
NEYNAR_API_KEY
NEXT_PUBLIC_NEYNAR_CLIENT_ID
api.neynar.com路径B — 若有意保留Neynar:
- 验证剩余的导入和环境变量仅存在于隔离的Farcaster功能模块及其服务端辅助工具内
@neynar
报告所有源文件匹配项,忽略、锁文件和git历史。
node_modules4B. Type Check
4B. 类型检查
bash
npx tsc --noEmitReport and fix type errors.
bash
npx tsc --noEmit报告并修复类型错误。
4C. Build Check
4C. 构建检查
bash
npm run buildReport and fix build errors.
bash
npm run build报告并修复构建错误。
4D. Conversion Summary
4D. 转换总结
undefinedundefinedConversion Complete — Path [X]: [Name]
转换完成 — 路径[X]:[名称]
Files modified: [count]
Files deleted: [count]
Files created: [count, if any]
Packages removed: [list]
Packages added: [list, if any]
修改的文件数: [数量]
删除的文件数: [数量]
创建的文件数: [数量(如有)]
移除的包: [列表]
添加的包: [列表(如有)]
What was done
已完成操作
- Removed Farcaster Mini App wagmi connector
- Stubbed or removed Mini App provider/context
- Replaced Mini App auth with normal web auth or removed it
- Removed or replaced SDK action calls
- Deleted manifest route
- Removed Farcaster meta tags
- Cleaned up dependencies and env vars
**Path B summary additionally includes:**- Kept the main app as a normal web app
- Confined remaining Farcaster functionality to a dedicated route/page
- Preferred read-only Farcaster data where possible
- Removed Farcaster host/runtime coupling from shared app infrastructure
**All paths end with:**- 移除Farcaster Mini App wagmi连接器
- 存根或移除Mini App提供者/上下文
- 将Mini App认证替换为常规Web认证或移除
- 移除或替换SDK操作调用
- 删除清单路由
- 移除Farcaster元标签
- 清理依赖项和环境变量
**路径B总结额外包含:**- 将主应用保留为常规Web应用
- 将剩余Farcaster功能限制在专用路由/页面内
- 尽可能优先使用只读Farcaster数据
- 从共享应用基础设施中移除Farcaster宿主/运行时耦合
**所有路径均以以下内容结尾:**Manual steps
手动步骤
- Run
npm install - Test wallet connection flow
- If FID migration is needed, migrate from FID-based identity to wallet address
- If Path B preserves a Farcaster-only area, verify it stays isolated from the main app shell
- 运行
npm install - 测试钱包连接流程
- 若需迁移FID,从基于FID的身份迁移至钱包地址
- 若路径B保留了Farcaster专属区域,验证其与主应用外壳保持隔离
Verification
验证结果
- TypeScript: [pass/fail]
- Build: [pass/fail]
- Remaining Farcaster references: [none / list]
---- TypeScript:[通过/失败]
- 构建:[通过/失败]
- 剩余Farcaster引用:[无 / 列表]
---Edge Cases
边缘情况
No wagmi
无wagmi
Skip Phase 2A. Do not introduce wagmi unless the app actually needs wallet connectivity.
跳过阶段2A。除非应用确实需要钱包连接,否则不要引入wagmi。
No auth system
无认证系统
Skip Phase 2C. Do not add SIWE unnecessarily.
跳过阶段2C。不要不必要地添加SIWE。
@farcaster/frame-sdk
(older)
@farcaster/frame-sdk@farcaster/frame-sdk
(旧版)
@farcaster/frame-sdkTreat identically to .
@farcaster/miniapp-sdk与处理方式相同。
@farcaster/miniapp-sdkMonorepo
单体仓库
Ask which workspace(s) to convert. Only modify those.
询问要转换哪个工作区。仅修改指定工作区。
FID as database primary key
FID作为数据库主键
Do not change schema automatically. Flag it and warn in Phase 4.
不要自动更改schema。在阶段4中标记并警告。
Conditional isInMiniApp
branches
isInMiniApp条件isInMiniApp
分支
isInMiniAppAlways keep the normal web branch and remove the Mini App branch.
始终保留常规Web分支,移除Mini App分支。
Components with no non-Farcaster purpose
仅在Farcaster内有意义的组件
Delete them entirely in . In , keep them only if they live inside the isolated Farcaster route/page.
Path APath B在中完全删除。在中,仅当它们位于隔离的Farcaster路由/页面内时才保留。
路径A路径BExisting Neynar usage
现有Neynar使用
If the project already uses Neynar:
- remove it in
Path A - keep it only if it remains inside the isolated surface
Path B - do not add more Neynar usage than already exists unless the user explicitly requests it
如果项目已使用Neynar:
- 在中移除
路径A - 在中,仅当它保留在隔离功能模块内时才保留
路径B - 除非用户明确要求,否则不要添加更多Neynar使用
Read-only is usually enough
只读通常已足够
If the user says they want to "keep Farcaster stuff," bias toward:
- profile links
- read-only profile or cast display
- a dedicated social page
Do not assume they want write access, notifications, or host/runtime behavior.
如果用户表示想“保留Farcaster相关功能”,优先偏向:
- 个人资料链接
- 只读个人资料或动态展示
- 专用社交页面
不要假设用户需要写入权限、通知或宿主/运行时行为。
Quiz ambiguity
问卷歧义
If the scan and quiz conflict, point it out and ask the user to confirm the smaller keep-surface first.
如果扫描结果与问卷答案冲突,指出该问题并先请用户确认最小保留功能模块。
Security
安全
- Validate wallet setup — ensure or the chosen wallet connector is configured correctly
coinbaseWallet - FID-based identity — requires manual database migration if used as a primary key
- SIWE verification — verify signatures server-side before trusting them
- Preserved isolated surface — do not let a Farcaster-only route/page leak host/runtime assumptions into the main app shell
- Existing Neynar usage — keep API keys server-side only, and only if that isolated surface still depends on them
- 验证钱包配置 — 确保或所选钱包连接器配置正确
coinbaseWallet - 基于FID的身份 — 若用作主键,需要手动数据库迁移
- SIWE验证 — 在信任签名前,在服务端验证签名
- 保留的隔离功能模块 — 不要让Farcaster专属路由/页面将宿主/运行时假设泄露到主应用外壳
- 现有Neynar使用 — 仅在服务端保留API密钥,且仅当隔离功能模块仍依赖时才保留