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

simple-sharer

v4.0.0

Published

A javascript framework to share url to social media platforms in an easy and simple way.

Downloads

81

Readme

simple-sharer [by BUILDBROTHERS.COM]

A javascript framework to share url to social media sites like facebook, twitter, reddit, linkedin, whastapp in an easy and simple way.

Star this project on GitHub https://github.com/Build-Brothers-NG/simple-sharer

Supported Javascript Frameworks:

  • React
    • Next Js
  • Vue
  • Angular

Features

  • share url to facebook
  • share url to reddit
  • share url to Whatsapp
  • share url to twitter
  • share url to linkedin
  • copy url to clipboard
  • Clean String

Simple-sharer is a lightweight (<4KB) javascript framework, which makes it very easy and simple to share URL to various social media sites. Simple-sharer is created by BuildBrothers.com

Here is how to get started with simple-sharer.

Installation

Install using NPM

npm i simple-sharer

Install using yarn

yarn add simple-sharer

Example 1 with React.js

import React from "react";
import { Simplesharer } from "./simplesharer";

function App() {
  const sh = new Simplesharer();
  sh.url = "www.buildbrothers.com"; //your url
  sh.title = "Build Brothers Website"; //title for reddit, this is optional
  sh.text = "Passionate Mobile and Web Apps Development Team"; // description for twitter, not more than a hundred characters, optional.
  sh.hashtags = ["buildbrothers", "bb", "software dev team"]; // a list of hashtags for twitter,also optional

  return (
    <div>
      {/* call the share method, passing the platform name as a parameter to share. */}
      <button onClick={() => sh.share("Facebook")}>share on facebook</button>
      <button onClick={() => sh.share("tWitter")}>share on twitter</button>
      <button onClick={() => sh.share("WHATSAPP")}>share on Whatsapp</button>
      {/* // Or directly call the platform as a method */}
      <button onClick={() => sh.linkedin()}>share on linkedin</button>
      <button onClick={() => sh.reddit()}>share on reddit</button>
      <button onClick={() => sh.copy()}>copy Link</button>
    </div>
  );
}
export default App;

Note:

The parameter for the share method is case insensitive, as long as it is a valid name, the function will get executed. the valid parameters are: facebook, twitter, reddit, linkedin, whatsapp, copy.

Example 2 with React.js

import React from "react";
// you can directly import these methods and use it without the Simplesharer class object
import {
  facebook,
  twitter,
  reddit,
  linkedin,
  copy,
  whatsapp,
} from "./simplesharer";

function App() {
  return (
    <div>
      <button onClick={() => facebook({ url: "www.buildbrothers.com" })}>
        share on facebook
      </button>
      <button
        onClick={() =>
          twitter({
            url: "www.buildbrothers.com",
            text: "Passionate Mobile and Web Apps  Development Team",
            hashtags: ["buildbrothers", "bb", "software dev team"],
          })
        }
      >
        share on twitter
      </button>
      {/* if no url is provided, it will use the current page url. */}
      <button onClick={() => whatsapp()}>share on Whatsapp</button>
      <button onClick={() => reddit({ title: "Build Brothers Website" })}>
        share on reddit
      </button>
      <button onClick={() => copy()}>copy Link</button>
    </div>
  );
}
export default App;

Note:

By default simple-sharer pop up a new window while sharing url, to use the parent window, you can change the target like this;

const sh = new Simplesharer()
sh.target = "_parent" //by default the target is _blank

When no url is defined, simple-sharer uses the current url of the page.

You can also clean a string, before sharing it to social media site using the cleanString function.

Example:

import React from 'react'
import { cleanString } from "simple-sharer";

function App(){
    const uncleanString = "The 'Quick'? Brown Fox Jump, Over The Lazy Dog;"
    const clean = cleanString(uncleanString) 
    //will return "the-quick-brown-fox-jump-over-the-lazt-dog"
    return (
    <div>
        <...../>
    </div>
    )
}
export default App;

Star this project on GitHub https://github.com/Build-Brothers-NG/simple-sharer

# License 

This program is licensed under the GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007. Please read the LICENSE.txt text document included with the source code if you would like to read the terms of the license.