跳到內容
Yuva subscribe hook選單

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

    預覽使用範例資料執行,不需要網路,也不需要頻道。

    安裝

    在 shadcn 專案中執行。檔案會複製到你自己的程式碼裡。

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

    用法

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

    Props

    UseYuvaSubscribeOptions

    Prop類型
    server?string
    channel?string
    client?YuvaClient
    identityToken?IdentityTokenSource | null
    lists?string[]

    YuvaSubscribeState

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

    相依套件

    安裝此項目時還會加入以下內容。

    npm 套件