@torquefi/react
v0.1.3
Published
React hooks for Torque Platform — Intelligence feeds and Assistant chat via merchant BFF routes
Maintainers
Readme
@torquefi/react
React hooks for Torque Platform surfaces. Call your merchant BFF — never put sk_live_… in the browser.
Published as @torquefi/react because the unscoped name torque-react is already taken on npm.
Install
yarn add @torquefi/react @torquefi/typesIntelligence feed
Implement a server route that proxies to torque-node / torque-intelligence, then:
'use client'
import { useIntelligenceFeed } from '@torquefi/react/intelligence'
export function HomeIntel({ walletAddress }: { walletAddress?: string }) {
const { items, isLoading, error, refresh } = useIntelligenceFeed({
walletAddress,
chainId: 8453,
includeBrief: true,
endpoint: '/api/torque/intelligence/feed',
})
if (isLoading) return <p>Loading…</p>
if (error) return <p>{error.message}</p>
return (
<ul>
{items.map((item) => (
<li key={item.id}>{item.title}</li>
))}
</ul>
)
}Assistant chat
'use client'
import { useAssistantChat } from '@torquefi/react/assistant'
export function DeskAssistant({ walletAddress }: { walletAddress: string }) {
const { send, streamText, isLoading, functionResults } = useAssistantChat()
return (
<>
<pre>{streamText}</pre>
<button
disabled={isLoading}
onClick={() =>
send({
content: 'What moved today?',
context: { walletAddress, chainId: 8453 },
stream: true,
})
}
>
Ask
</button>
{functionResults?.length ? <pre>{JSON.stringify(functionResults, null, 2)}</pre> : null}
</>
)
}Default BFF paths:
GET /api/torque/intelligence/feedPOST /api/torque/assistant/chat
Docs
- SDK roadmap
torque-nodefor server route handlers
License
MIT
