Usage

Learn how to use the newsletter module in your Nuxt 3 application.


This module exposes composables and components that are auto-imported by Nuxt 3.

Module registration

In order to use nuxt-newsletter module in your Nuxt application, make sure to register the module with its options in nuxt.config.ts like following:

nuxt.config.js|ts
export default defineNuxtConfig({  modules: [    'nuxt-newsletter'  ],  newsletter: {    revue: {      apiKey: '<REVUE_API_KEY>',      component: true    }  }})

You can read about module configuration options here

Use NewsletterForm.vue in your app

Right now, you can use the built in newsletter-form component in your application like following:

<template>  <div>    <newsletter-form />  </div></template>

You can read more about components in the Components section.

useNewsletterSubscribe composable

If you prefer to create your own newsletter component you can use the built in useNewsletterSubscribe composable to handle adding new email address to subscribers like following:

<script setup>const result = await useNewsletterSubscribe(email.value)console.log(result) // Email ${email} added to subscribers</script>