Skip to content
Shopware

useNewsletter

useNewsletter

Composable for newsletter subscription.

Types

ts
export function useNewsletter(): UseNewsletterReturn

source code

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<Schemas["AccountNewsletterRecipient"]>;
  /**
   * 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["AccountNewsletterRecipient"]["status"]>;
  /**
   * Inform about newsletter confirmation
   */
  confirmationNeeded: ComputedRef<boolean>;
};

source code