Open source libraryBrought to you by AOSSIE (opens in a new tab)
Lightweight social share button library for modern websites
Zero dependencies. Framework-agnostic. Designed for technical precision and extreme performance.
Install with npm
npm install @aossie-org/social-share-buttonInstallation steps
- Your framework
- Pick your framework above and the exact code to copy will appear here.
Trusted by builders at
AOSSIE, DJED, Stability Nexus
Features
Everything a share button needs. Nothing it doesn't.
15KB
dependencies: 0
Zero dependencies
Pure vanilla JavaScript and one stylesheet, about 15 KB gzipped. No framework runtime, no icon font, no tracking SDK.
- X
- Telegram
- Discord
Nine platforms, one button
A single share button opens a clean modal with every network your audience uses, plus copy-to-clipboard.
Themes and styles built in
Light and dark themes, four button styles and your own brand colors. No CSS required.
- Google Analytics 4
- Mixpanel
- Segment
- Plausible
- PostHog
Privacy-first analytics
The library never sends data anywhere. It emits share events you can forward to Google Analytics, Mixpanel, Segment, Plausible or PostHog.
By the numbers
Small enough to forget it is there.
- KB gzipped, JS + CSS
- 15
- runtime dependencies
- 0
- share targets
- 9
- frameworks with copy-paste guides
- 6
Why switch?
No bloat. No paywalls. Just code.
Hosted share widgets load third-party scripts that can track your visitors and slow your pages down. Social Share Button is one small script and one stylesheet that you control.
| Feature | Social Share Button | Hosted share widgets |
|---|---|---|
| Bundle size | 15 KB gzipped | Remote script, size varies |
| Network calls by the widget | None | Several per page view |
| Visitor tracking | None | Common |
| Cookie banner needed | No | Often |
| Custom styling | Full CSS control | Limited |
| Open source | Yes, GPL-3.0 | Rarely |
Use cases
Wherever people want to pass it on.
Anything with a URL deserves a share button. These are the places it earns its keep.
- 01
Blogs and publications
Let readers send an article to WhatsApp or X the moment they finish it, with the title and description included.
- 02
Documentation sites
Help developers share the exact page that solved their problem, even in single-page doc sites.
- 03
Product pages
Turn a product link into a conversation on Pinterest, WhatsApp or Email without a heavy plugin.
- 04
Open-source projects
Make it one click to tell a community about your release, with your hashtags and handle baked in.
- 05
Portfolios
Give recruiters and clients an easy way to forward your work to LinkedIn or their team.
- 06
Events and campaigns
Spread a launch, meetup or fundraiser across every network and track shares with your own analytics.
Modular architecture
A tiny core. Everything else is optional.
Load the core from a CDN and stop there, or add the pieces you need. Nothing is bundled that you did not ask for.
Delivery
Use the jsDelivr CDN with a pinned version, or install from npm.
- cdn.jsdelivr.net
- npm i @aossie-org/social-share-button
Core
The share button, modal and copy-to-clipboard. Works on its own in any page.
- social-share-button.js
- social-share-button.css
Framework wrappers
Optional thin components for React, Preact and Qwik. Copy one into your project if you prefer JSX.
- -react.jsx
- -preact.jsx
- -qwik.tsx
Analytics adapters
Opt-in adapters that forward share events to the tool you already use.
- social-share-analytics.js
Three ways to listen for events
- DOM CustomEvent: listen for social-share on document
- onAnalytics callback: one function, one place
- analyticsPlugins: send to several providers at once
FAQs
Questions, answered.
Is Social Share Button free to use?
Yes. It is open source under the GNU General Public License v3.0 and maintained by the AOSSIE community.
Does it track my visitors?
No. The library never collects, stores or sends data. It only emits events inside the browser, and you decide whether to forward them to an analytics tool.
Which frameworks does it work with?
Any. It is plain JavaScript, so it runs in plain HTML, React, Next.js, Preact, Vue, Angular, Qwik and more. The installation steps above have copy-paste code for the most common setups.
Can I choose which platforms appear?
Yes. Pass the platforms option, for example platforms: ["linkedin", "twitter", "email"]. Available platforms are WhatsApp, Facebook, X, LinkedIn, Telegram, Reddit, Email, Pinterest and Discord.
Can I match it to my brand?
Yes. Choose a light or dark theme, one of four button styles (default, primary, compact, icon-only), set buttonColor and buttonHoverColor, or add your own CSS class with customClass.
Will the shared link update when my single-page app changes route?
Yes. When you do not pass a fixed url, the library listens for client-side navigation and updates the link automatically. You can also call updateOptions() yourself.
The button does not appear. What should I check?
Make sure the stylesheet link is inside the page head, the script has loaded before you initialize, and the container selector matches your element. For example, container: "#share-button" needs an element with id="share-button".
Can I install it from npm instead of a CDN?
Yes. Run npm install @aossie-org/social-share-button, then import the module and its stylesheet in your code.
Testimonials
Built in the open, shaped by its users.
Your story could be the first one here.
Shipping Social Share Button in production? Tell us what you built and we will feature it on this page.