[SDK] @flowfi/react: Headless React Hooks & UI Primitives for Embedding Payment Streams
Overview & Background
Third-party Stellar dApps, DAO governance frontends, and SaaS dashboards frequently want to embed payment streaming (e.g. "Subscribe via FlowFi Stream" or "Claim Grant") into their own applications. Forcing external developers to build custom contracts interaction or copy-paste React context logic creates adoption friction. FlowFi should offer an official, tree-shakable @flowfi/react package containing headless hooks, state machines, and accessible UI primitives.
Detailed Problem Statement
- High Integration Barrier:
- External frontend developers must manually manage Soroban RPC calls, XDR parsing, SSE event listeners, and real-time interval tickers.
- Duplicated Real-Time Math:
- Calculating real-time claimable balance with sub-second animation, cliff periods, paused durations, and decimal scaling is complex and prone to bugs when re-implemented.
- No Drop-In Component Kit:
- There are no headless or pre-styled components (e.g.
<StreamButton />,<ClaimableTicker />,<RunwayBadge />) that developers can drop into any Next.js or React app.
- There are no headless or pre-styled components (e.g.
Technical Specification & Architecture
1. Package Architecture (packages/flowfi-react)
Create a new workspace package:
packages/flowfi-react/
├── src/
│ ├── hooks/
│ │ ├── useStream.ts
│ │ ├── useClaimableBalance.ts
│ │ ├── useCreateStream.ts
│ │ ├── useBatchWithdraw.ts
│ │ └── useStreamRunway.ts
│ ├── components/
│ │ ├── FlowFiProvider.tsx
│ │ ├── ClaimableTicker.tsx
│ │ ├── StreamRunwayProgress.tsx
│ │ └── StreamActionModal.tsx
│ └── index.ts
├── package.json
└── tsconfig.json
2. Core Headless Hooks
useClaimableBalance(streamId):- Automatically updates balance using requestAnimationFrame or sub-second interval.
- Automatically handles cliff unlocks, rate conversions, and token decimals.
useCreateStream():- Provides state machine (
idle,simulating,signing,broadcasting,confirmed,error). - Automatically simulates fees, builds Soroban transaction envelope, prompts connected wallet, and waits for confirmation.
- Provides state machine (
useBatchWithdraw():- Handles multi-stream selection, gas estimation, and batch transaction dispatch.
3. Component Primitives
<ClaimableTicker stream={stream} format="usd" animated={true} />: Smooth liquid continuous number ticker.<StreamRunwayProgress stream={stream} alertThresholdHours={48} />: Visual progress bar indicating time left before exhaustion.
Target Files
packages/flowfi-react/package.jsonpackages/flowfi-react/src/hooks/useClaimableBalance.tspackages/flowfi-react/src/hooks/useCreateStream.tspackages/flowfi-react/src/components/FlowFiProvider.tsxpackages/flowfi-react/src/components/ClaimableTicker.tsxpackages/flowfi-react/tests/useClaimableBalance.test.tsx
Acceptance Criteria
- [ ]
@flowfi/reactbuilds cleanly into ESM and CJS bundles with full TypeScript definitions. - [ ]
useClaimableBalancedelivers smoothly animated numbers matching on-chain claimable calculations. - [ ]
useCreateStreamproperly handles transaction simulation, wallet signing, and indexer confirmation. - [ ] Primitives work seamlessly with Tailwind CSS and popular UI frameworks (shadcn/ui, Radix UI).
- [ ] Comprehensive unit tests cover hook lifecycles, cliff edge-cases, and wallet error handling.
@bright5455 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
hello maintainer
i have read and understand the issue im a backend engineer with five years of eperience,with my level of experience,i believe i can deliver a quality PR please kindly assign this task to me
Thank you
ℹ️ Repo Maintainers: To accept this application, review their application or assign @bright5455 to this issue.
@Victorjonah-prog has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
Hi maintainer, I've reviewed this issue and I'll love to work on it
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Victorjonah-prog to this issue.
Congratulations, @bright5455! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.
🧑💻 @bright5455: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
🎉 This issue has been marked as completed on GrantFox!
@bright5455's PR #1587 was approved and merged by @K1NGD4VID.
🏆 @bright5455: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,169 total points). Track your full progress on GrantFox.
👏 Great work, @bright5455! Keep contributing to LabsCrypt.