Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hatchly/nuxt-newsletter-module

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hatchly/nuxt-newsletter-module

Official nuxt integration for the Hatchly/Newsletter module

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
3
Weekly downloads
 
Created
Source

Nuxt Hatchly Newsletter Module

Module to easily integrate with the Hatchly Newsletter module

Installation

yarn add @hatchly/nuxt-newsletter-module

Register the module in your nuxt applications config file:

module.exports = {
    // Nuxt config
    modules: {
        // Other Modules
        ['@hatchly/nuxt-newsletter-module', {
            // Options
        }],
    },

    hatchly: {
        newsletter: {
            // Options can also be defined here
        },
    },
};

Add the API url to your .env:

API_BASE=http://my-application.localhost

Options

The options object can contain the following values:

{
    baseURL: '',
    browserBaseURL: '',
},

Each option is described below.

baseURL

The url of your Hatchly site. If browserBaseURL is not provided this url will be used for both server side and client side fetching.

  • Default: process.env.API_URL
  • Type: string

browserBaseURL

The public url of your Hatchly site.

  • Default: process.env.API_URL_BROWSER
  • Type: string

Runtime config

If using nuxt runtime config to inject env variables at runtime, each of the above options can be overwritten in both publicRuntimeConfig and privateRuntimeConfig objects, for example:

module.exports = {
    publicRuntimeConfig: {
        hatchly: {
            // Inherit options for all hatchly modules
            baseURL: process.env.API_URL,
            
            newsletter: {
                // Overwrite options for the newsletter module
                baseURL: process.env.API_URL,
            },
        },    
    },
};

Usage

This module will register a Vuex module for interacting with the newsletter api, and provides a vuex action for you to call within your application:

<template>
    <form @submit.prevent="handleSubmit">
        <input type="email" v-model="formData.email">
    </form>
</template>

<script>
    import { mapActions } from 'vuex';

    export default {
        name: 'newsletter-form',

        data() {
            return {
                formData: {
                    email: '',
                },            
            };
        },

        methods: {
            ...mapActions('newsletter', ['subscribe']),

            async handleSubmit() {
                try {
                    await this.subscribe(this.formData);
                } catch (e) {
                    // Handle errors
                }   
            },
        },
    };
</script>

FAQs

Package last updated on 26 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc