loading
प्रिव्यू नमूना डेटा पर चलता है। इसे न नेटवर्क चाहिए, न चैनल।
tsx
import { useYuvaChat } from "@/hooks/use-yuva-chat"
export function Inbox() {
const chat = useYuvaChat({
server={process.env.NEXT_PUBLIC_YUVA_SERVER}
channel={process.env.NEXT_PUBLIC_YUVA_CHANNEL},
})
return (
<ul>
{chat.conversations.map((conversation) => (
<li key={conversation.id}>
<button onClick={() => void chat.open(conversation.id)}>{conversation.subject}</button>
</li>
))}
</ul>
)
}इंस्टॉलेशन
इसे किसी shadcn प्रोजेक्ट में चलाएँ। फ़ाइलें आपके अपने कोड में कॉपी हो जाती हैं।
Shell
npx shadcn@latest add https://useyuva.com/r/use-yuva-chat.jsonShell
pnpm dlx shadcn@latest add https://useyuva.com/r/use-yuva-chat.jsonShell
yarn dlx shadcn@latest add https://useyuva.com/r/use-yuva-chat.jsonShell
bunx --bun shadcn@latest add https://useyuva.com/r/use-yuva-chat.jsonउपयोग
tsx
import { useYuvaChat } from "@/hooks/use-yuva-chat"
const chat = useYuvaChat({ server, channel })Props
UseYuvaChatOptions
| Prop | प्रकार |
|---|---|
server? | string |
channel? | string |
client? | YuvaClient |
identityToken? | IdentityTokenSource | null |
helpArticleId? | string |
YuvaChatState
| Prop | प्रकार |
|---|---|
loading | boolean |
error | unknown |
inbox | ClientInbox | null |
contact | ClientContact | null |
connection | ConnectionState["state"] |
conversations | ClientConversation[] |
hasMoreConversations | boolean |
loadMoreConversations | () => Promise<void> |
activeId | string | null |
conversation | ClientConversation | null |
open | (id: string | null) => Promise<void> |
removed | boolean |
threadLoading | boolean |
messages | YuvaChatMessage[] |
hasEarlier | boolean |
loadEarlier | () => Promise<void> |
typing | ClientMessage["author"] | null |
memberReadAt | string | null |
send | (input: YuvaChatSendInput) => Promise<void> |
retry | (id: string) => Promise<void> |
discard | (id: string) => void |
setTyping | (on: boolean) => void |
markRead | () => Promise<void> |
rate | (rating: Rating, comment?: string) => Promise<void> |
openAttachment | (attachment: ClientAttachment) => Promise<void> |
saveEmail | (email: string) => Promise<void> |
निर्भरताएँ
इस आइटम को इंस्टॉल करने से नीचे दिए गए भी जुड़ जाते हैं।