Chuyển đến nội dung
Yuva subscribe hookMenu

Yuva subscribe hook

A React hook over the useyuva headless client: the channel's public mailing lists, subscribing from a form with its form token, and the signed-in user's subscriptions with an identity token.

Loading

    Bản xem trước chạy trên dữ liệu mẫu. Không cần mạng hay kênh.

    Cài đặt

    Chạy lệnh này trong một dự án shadcn. Các tệp được sao chép vào mã của bạn.

    Shell
    npx shadcn@latest add https://useyuva.com/r/use-yuva-subscribe.json

    Cách dùng

    tsx
    import { useYuvaSubscribe } from "@/hooks/use-yuva-subscribe"
    
    const { lists, states, subscribe, setSubscribed } = useYuvaSubscribe({ server, channel })

    Props

    UseYuvaSubscribeOptions

    PropKiểu
    server?string
    channel?string
    client?YuvaClient
    identityToken?IdentityTokenSource | null
    lists?string[]

    YuvaSubscribeState

    PropKiểu
    inboxNamestring
    listsClientMailingList[]
    statesRecord<string, SubscriptionState | undefined>
    identifiedboolean
    loadingboolean
    errorunknown
    subscribe(input: YuvaSubscribeInput) => Promise<{ confirmation: boolean }>
    setSubscribed(listId: string, on: boolean, consentText: string) => Promise<SubscriptionState>

    Phụ thuộc

    Cài mục này cũng sẽ thêm các mục sau.

    Gói npm