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

viral-loops-react

v0.1.0

Published

Unofficial React component wrapper for https://viral-loops.com

Downloads

50

Readme

viral-loops-react

React component wrapper for https://viral-loops.com/ script.

Install

yarn add viral-loops-react
# or
npm install viral-loops-react

Usage

Setting up your Viral Loops component involves 3 steps:

  1. Installing the Viral Loops script.
  2. Importing the ViralLoops module.
  3. Configuring the <ViralLoops /> component.

1: Install the Viral Loops script

First, log in to your Viral Loops dashboard via your account. Next, select the campaign you're interested in, click the "edit" button, then, in the footer of the page, click the "Installation" link.

On this page, select "I'll do it myself", and copy/paste the revealed script into the file that renders the root of your React application. For create-react-app users, this will be your public/index.html file.

To finish off this step, get the "Campaign ID" public token from the same page as the script you just copied, and include it in your project as an environment variable.

2: Import the ViralLoops module

Secondly, import the ViralLoops module into the view where you want the Viral Loops widgets to be displayed.

import ViralLoops from 'viral-loops-react';

In preparation for the next step, you'll also need to import the Viral Loops "Campaign ID" that you stored in an environment variable at the end of the previous step.

e.g. (assuming you're using dotenv to manage env vars)

# in .env
REACT_APP_VIRAL_LOOPS_CAMPAIGN_ID='yourCampaignID'

Note: If you're using create-react-app and the env var's name isn't prefixed with "REACT_APP" it will not be included in the build. This is a create-react-app convention.

# in config.js
const config = {
  viralLoopsCampaignId: process.env.REACT_APP_VIRAL_LOOPS_CAMPAIGN_ID
}

# in your view's file
import config from './config';

3: Configure the <ViralLoops /> component

Lastly, declare the component, passing it the necessary props to get the widgets you want.

Valid props are:

publicToken: 'string' (required)

formWidget: 'boolean' (optional) <--- displays the "Form" widget

milestoneWidget: 'boolean' (optional) <--- displays the "Milestones" widget

counterWidget: 'boolean' (optional) <--- displays the "Referral Counter" widget

e.g.

<ViralLoops 
  publicToken={config.viralLoopsKey}
  formWidget
  milestoneWidget
/>

Note:

viral-loops-react does not support Internet Explorer 11, due to errors that are thrown by the Viral Loops script when included in projects generated by create-react-app.