Hoppa till innehållet
Yuva subscribe hookMeny

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

    Förhandsvisningen använder exempeldata. Den behöver varken nätverk eller kanal.

    Installation

    Kör detta i ett shadcn-projekt. Filerna kopieras in i din egen kod.

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

    Användning

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

    Props

    UseYuvaSubscribeOptions

    PropTyp
    server?string
    channel?string
    client?YuvaClient
    identityToken?IdentityTokenSource | null
    lists?string[]

    YuvaSubscribeState

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

    Beroenden

    När du installerar det här elementet läggs även följande till.

    npm-paket