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

@viral-loops/widgets

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@viral-loops/widgets

> This repo is in beta, if you find any bugs please contact our support!

  • 0.4.35
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4.4K
increased by11.2%
Maintainers
1
Weekly downloads
 
Created
Source

Viral Loops Widgets for React, Vue, Angular, Svelte and Solid

This repo is in beta, if you find any bugs please contact our support!

npm install @viral-loops/widgets

React Installation

// App.jsx

import { useState, useEffect } from 'react';
import logo from './assets/react.svg';
import './App.css';
import { ViralLoopsWidget, getCampaign } from '@viral-loops/widgets/dist/react';

function App() {
	const [vlUser, setVlUser] = useState();

	const VIRAL_LOOPS_CAMPAIGN_ID = 'iev8dcEBHtsNToNqaCGnXGGCmsc'; // replace with your campaign ID

	async function logout() {
		const campaign = await getCampaign(VIRAL_LOOPS_CAMPAIGN_ID);
		campaign?.logout();
		window.location.reload();
	}

	async function bindViralLoopsUser() {
		if (vlUser) return;

		const campaign = await getCampaign(VIRAL_LOOPS_CAMPAIGN_ID);
		const loggedInUser = campaign.getUser();

		if (loggedInUser) {
			console.log('[Viral Loops] user logged in to viral loops is:', loggedInUser);
			setVlUser(loggedInUser);
		} else {
			campaign.on('participation', (vlUser) => {
				console.log('[Viral Loops] user participated to viral loops!', vlUser);
				setVlUser(vlUser);
			});
		}
	}

	useEffect(() => {
		bindViralLoopsUser();
	});

	return (
		<>
			<div className="App">
				<img src={logo} alt="" />
				<h1> The Company Name </h1>

				<div className="card">
					<ViralLoopsWidget ucid={VIRAL_LOOPS_CAMPAIGN_ID} />

					{vlUser && (
						<div>
							<h2>
								{' '}
								You're logged in as
								<span> {vlUser.email} </span>
							</h2>
							<p> Invite your friends! (You currently have {vlUser.referralCount} referrals) </p>
							<button onClick={() => logout()}> Logout </button>
						</div>
					)}
				</div>
			</div>
		</>
	);
}
Installation instructions for other frameworks are on the works! If you have questions please contact our support team!

FAQs

Package last updated on 15 Dec 2022

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