Appearance
useNewsletter ​
Definition ​
Composable for newsletter subscription.
Basic usage ​
ts
const {
isNewsletterSubscriber,
newsletterStatus,
confirmationNeeded,
newsletterSubscribe,
newsletterUnsubscribe,
getNewsletterStatus
} = useNewsletter();
Signature ​
ts
export function useNewsletter(): UseNewsletterReturn
Return type ​
See UseNewsletterReturn
ts
export type UseNewsletterReturn = {
/**
* Subscribes the user to the newsletter
* @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
*/
newsletterSubscribe(
params: Omit<
operations["subscribeToNewsletter post /newsletter/subscribe"]["body"],
"storefrontUrl"
>,
): Promise<void>;
/**
* Removes the email from the newsletter
* @param email
*/
newsletterUnsubscribe(email: string): Promise<void>;
/**
* Get newsletter status from the API call
*/
getNewsletterStatus(): Promise<void>;
/**
* Indicates if the user is subscribed to the newsletter
*
* Returns `true` if the user is subscribed to the newsletter, `false` otherwise
*/
isNewsletterSubscriber: ComputedRef<boolean>;
/**
* Newsletter status
*/
newsletterStatus: Ref<Schemas["AccountNewsletterRecipientResult"]["status"]>;
/**
* Inform about newsletter confirmation
*/
confirmationNeeded: ComputedRef<boolean>;
};
Properties ​
Name | Type | Description |
---|---|---|
isNewsletterSubscriber | ComputedRef<boolean> | Indicates if the user is subscribed to the newsletterReturns `true` if the user is subscribed to the newsletter, `false` otherwise |
newsletterStatus | Ref<> | Newsletter status |
confirmationNeeded | ComputedRef<boolean> | Inform about newsletter confirmation |
Methods ​
Name | Type | Description |
---|---|---|
newsletterSubscribe | Promise<void> | Subscribes the user to the newsletter |
newsletterUnsubscribe | Promise<void> | Removes the email from the newsletter |
getNewsletterStatus | Promise<void> | Get newsletter status from the API call |