npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-mailchimp-email-signup-form

v2.0.2

Published

Easily collect email signups using MailChimp in your React projects.

Downloads

50

Readme

react-mailchimp-email-signup-form

Easily collect email signups using MailChimp in your React projects.

Links

View demo

View on npm

View on GitHub

Vue Version

Check out the Vue version!

Install

Package Manager

# npm
npm i react-mailchimp-email-signup-form

# yarn
yarn add react-mailchimp-email-signup-form

Use

CSS

// css import for when you want to import the component css into your css file/files
@import '/path/to/node_modules/react-mailchimp-email-signup-form/dist/esm/index.css';
// javascript import for when you're importing the css directly in your javascript
import 'react-mailchimp-email-signup-form/dist/esm/index.css';

React

import React from 'react';
import { ReactMailchimpEmailSignupForm } from 'react-mailchimp-email-signup-form';

// Here's a usage example when using functional components
export const SignupForm = () => (
  <ReactMailchimpEmailSignupForm
    elementId="first-email-signup-form"
    url="https://XX.us4.list-manage.com/subscribe/post?u=XXXXXXXXXXXXXX"
    title="Subscribe to the Newsletter"
    subtitle="We take privacy seriously and we'll never spam or sell your information."
  />
);

About

This is just a really simple component that let's you use MailChimp's awesome email signup form but with a little bit more of a modern style. Normally for a component this simple I wouldn't really think to share it, but it ends up being really nice to use in things like Gatsby sites where you really don't want to bring a backend anywhere near your site. It's super easy to use - just follow the steps below to generate the url prop you need to pass to the component.

Go to your MailChimp admin. Click on Create, the Signup Form. Now, choose your audience, and stay on the Embedded form option and click Begin.

On the next screen, you'll see some demos for some embedded forms MailChip is offering. We don't want those - but we do want to url they bring. Go into the form and grab the url from the <form></form> action attribute. For me, this looks something like the following:

https://XXXXX.us4.list-manage.com/subscribe/post?u=XXXXXXXXXXXXXXXXXXXXXXXX&id=XXXXXXXXXX

This may look different in your case. Make sure you replace &amp; with an actual & if it gets copied like that.

That's it! Just add an elementId, title, and an optional subtitle and you're off.

You can see this form in action on my blog.

Notes

I looked into using the MailChimp API option, but that is not going to work from a purely static-type of site. So, while this does have your users leave the page, it ends up being a great option because you really don't have to do anything with any backend at all. Just make sure you have the proper site settings set up so it redirects users back to your blog or whatever. You do this on MailChimp's side.

Props

| prop | type | required | default | possible values | description | | --------- | ------ | -------- | ------- | --------------- | -------------------------------------------------------- | | elementId | String | Yes | | | A unique string form your element. | | url | String | Yes | | | The particular form post url from your MailChimp page. | | title | String | Yes | | | A title for your signup form. | | subtitle | String | No | | | A subtitle for your signup form. |

SCSS Structure

.subscribe-container {
  form {
  }

  &__title {
  }

  &__subtitle {
  }

  &__email {
  }

  &__submit {
    &:hover {
    }
  }
}

Development

# Install dependencies
yarn

# Serve with hot reloading and Storybook
yarn storybook:start

# Run the tests
yarn test:unit

# Build everything and run tests
yarn build

Other

Go ahead and fork the project! Submit an issue if needed. Have fun!

Thank You

Thank you to MailChimp.

License

MIT