{"_id":"@aossie-org/social-share-button","name":"@aossie-org/social-share-button","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.4":{"name":"@aossie-org/social-share-button","version":"1.0.4","description":"Lightweight social sharing component for web applications","main":"src/social-share-button.js","scripts":{"lint":"eslint src/**/*.{js,jsx} --max-warnings=0","lint:fix":"eslint src/**/*.{js,jsx} --fix","format":"prettier --write \"**/*.{js,jsx,json,css,md,html}\"","format:check":"prettier --check \"**/*.{js,jsx,json,css,md,html}\""},"repository":{"type":"git","url":"git+https://github.com/AOSSIE-Org/SocialShareButton.git"},"keywords":["social-share","share-button","vanilla-js","react","zero-dependencies","social-media","share","whatsapp","facebook","twitter","linkedin"],"author":{"name":"AOSSIE"},"license":"GPL-3.0","bugs":{"url":"https://github.com/AOSSIE-Org/SocialShareButton/issues"},"homepage":"https://github.com/AOSSIE-Org/SocialShareButton#readme","devDependencies":{"@eslint/js":"^9.39.4","eslint":"^9.39.4","globals":"^17.4.0","prettier":"^3.2.4"},"type":"module","packageManager":"pnpm@10.26.1+sha512.664074abc367d2c9324fdc18037097ce0a8f126034160f709928e9e9f95d98714347044e5c3164d65bd5da6c59c6be362b107546292a8eecb7999196e5ce58fa","_id":"@aossie-org/social-share-button@1.0.4","gitHead":"a6f84fa2b8f33c82e22b1d78a7f88bb67136662d","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-k6SfZOOCBt08944oqnxIr6GAmTZrik1/o2YmKRgZ2V1Ow08qOWj6PT/A23gtjfY4H2MJY0l2op4M6s0M3HKy+Q==","shasum":"8e970e9bd6139af674c3c47fe8b5c447e9199084","tarball":"https://registry.npmjs.org/@aossie-org/social-share-button/-/social-share-button-1.0.4.tgz","fileCount":7,"unpackedSize":107571,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDwjJD50NI6mYx2bbMWwFFySqPpS0dduv3ndxNwwlzXIQIhAJ8eBA38cFt560v/7ut5yrEFB9xWmGjBibQYENbDUk5G"}]},"_npmUser":{"name":"kpj2006","email":"24ucs074@lnmiit.ac.in"},"directories":{},"maintainers":[{"name":"zahnentferner","email":"zahnentferner@gmail.com"},{"name":"kpj2006","email":"24ucs074@lnmiit.ac.in"},{"name":"atharva0506","email":"atharvan.coder@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/social-share-button_1.0.4_1784442652298_0.5795522403896574"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-19T06:30:52.043Z","1.0.4":"2026-07-19T06:30:52.458Z","modified":"2026-07-19T06:30:52.886Z"},"maintainers":[{"name":"zahnentferner","email":"zahnentferner@gmail.com"},{"name":"kpj2006","email":"24ucs074@lnmiit.ac.in"},{"name":"atharva0506","email":"atharvan.coder@gmail.com"}],"description":"Lightweight social sharing component for web applications","homepage":"https://github.com/AOSSIE-Org/SocialShareButton#readme","keywords":["social-share","share-button","vanilla-js","react","zero-dependencies","social-media","share","whatsapp","facebook","twitter","linkedin"],"repository":{"type":"git","url":"git+https://github.com/AOSSIE-Org/SocialShareButton.git"},"author":{"name":"AOSSIE"},"bugs":{"url":"https://github.com/AOSSIE-Org/SocialShareButton/issues"},"license":"GPL-3.0","readme":"# <!-- Don't delete it -->\r\n\r\n<div name=\"readme-top\"></div>\r\n\r\n> ⚠️ **IMPORTANT**\r\n>\r\n> All project discussions happens on **[Discord](https://discord.com/channels/1022871757289422898/1479012884209078365)**.\r\n>\r\n> Please join the server **before opening PRs or Issues** and notify/tag the maintainer.  \r\n> Failing to do so may cause **delays in review**.\r\n>\r\n> **Maintainer:** @kpj2006\r\n\r\n<!-- Organization Logo -->\r\n<div align=\"center\" style=\"display: flex; align-items: flex-end; justify-content: center; gap: 16px;\">\r\n  <img alt=\"Social Share Button\" src=\"public/socialshare.png\" height=\"150\">\r\n  <img alt=\"AOSSIE\" src=\"public/aossie_logo.svg\" height=\"130\">\r\n</div>\r\n\r\n&nbsp;\r\n\r\n<!-- Organization Name -->\r\n<div align=\"center\">\r\n\r\n[![Static Badge](https://img.shields.io/badge/AOSSIE-Social_Share_Button-228B22?style=for-the-badge&labelColor=FFC517)](https://github.com/AOSSIE-Org/SocialShareButton)\r\n\r\n<!-- Correct deployed url to be added -->\r\n\r\n</div>\r\n\r\n<!-- Organization/Project Social Handles -->\r\n<p align=\"center\">\r\n<!-- Telegram -->\r\n<a href=\"https://t.me/StabilityNexus\">\r\n<img src=\"https://img.shields.io/badge/Telegram-black?style=flat&logo=telegram&logoColor=white&logoSize=auto&color=24A1DE\" alt=\"Telegram Badge\"/></a>\r\n&nbsp;&nbsp;\r\n<!-- X (formerly Twitter) -->\r\n<a href=\"https://x.com/aossie_org\">\r\n<img src=\"https://img.shields.io/twitter/follow/aossie_org\" alt=\"X (formerly Twitter) Badge\"/></a>\r\n&nbsp;&nbsp;\r\n<!-- Discord -->\r\n<a href=\"https://discord.gg/hjUhu33uAn\">\r\n<img src=\"https://img.shields.io/discord/1022871757289422898?style=flat&logo=discord&logoColor=white&logoSize=auto&label=Discord&labelColor=5865F2&color=57F287\" alt=\"Discord Badge\"/></a>\r\n&nbsp;&nbsp;\r\n<!-- Medium -->\r\n<a href=\"https://news.stability.nexus/\">\r\n  <img src=\"https://img.shields.io/badge/Medium-black?style=flat&logo=medium&logoColor=black&logoSize=auto&color=white\" alt=\"Medium Badge\"></a>\r\n&nbsp;&nbsp;\r\n<!-- LinkedIn -->\r\n<a href=\"https://www.linkedin.com/company/aossie/\">\r\n  <img src=\"https://img.shields.io/badge/LinkedIn-black?style=flat&logo=LinkedIn&logoColor=white&logoSize=auto&color=0A66C2\" alt=\"LinkedIn Badge\"></a>\r\n&nbsp;&nbsp;\r\n<!-- Youtube -->\r\n<a href=\"https://www.youtube.com/@StabilityNexus\">\r\n  <img src=\"https://img.shields.io/youtube/channel/subscribers/UCZOG4YhFQdlGaLugr_e5BKw?style=flat&logo=youtube&logoColor=white&logoSize=auto&labelColor=FF0000&color=FF0000\" alt=\"Youtube Badge\"></a>\r\n</p>\r\n\r\n---\r\n\r\n<div align=\"center\">\r\n<h1>SocialShareButton</h1>\r\n</div>\r\n\r\nLightweight social sharing component for web applications. Zero dependencies, framework-agnostic.\r\n\r\n[![npm version](https://img.shields.io/npm/v/@aossie-org/social-share-button.svg)](https://www.npmjs.com/package/@aossie-org/social-share-button)\r\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](LICENSE)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🌐 Multiple platforms: WhatsApp, Facebook, X, LinkedIn, Telegram, Reddit, Email, Pinterest, Discord\r\n- 🎯 Zero dependencies - pure vanilla JavaScript\r\n- ⚛️ Framework support: React, Preact, Next.js, Qwik, Vue, Angular, or plain HTML\r\n- 🔄 Auto-detects current URL and page title\r\n- 📱 Fully responsive and mobile-ready\r\n- 🎨 Customizable themes (dark/light)\r\n- ⚡ Lightweight (< 10KB gzipped)\r\n\r\n---\r\n\r\n## Installation\r\n\r\n### Via CDN (Recommended)\r\n\r\n```html\r\n<link\r\n  rel=\"stylesheet\"\r\n  href=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.css\"\r\n/>\r\n<script src=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.js\"></script>\r\n```\r\n\r\n---\r\n\r\n## Quick Start Guide\r\n\r\n> 🚫 **IMPORTANT:** Do NOT create new files like `ShareButton.jsx` or `ShareButton.tsx`!  \r\n> ✅ Add code directly to your **existing** component (Header, Navbar, etc.)\r\n\r\n### 🗺️ Integration Overview\r\n\r\nNo matter which framework you use, integration always follows the same 3 steps:\r\n\r\n| Step                 | What to do                                                   | Where                                                                                          |\r\n| -------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |\r\n| **1️⃣ Load Library**  | Add CSS + JS (CDN links)                                     | Global layout file — `index.html` / `layout.tsx` / `_document.tsx`                             |\r\n| **2️⃣ Add Container** | Place `<div id=\"share-button\"></div>`                        | The UI component where you want the button to appear                                           |\r\n| **3️⃣ Initialize**    | Call `new SocialShareButton({ container: \"#share-button\" })` | Inside that component, after the DOM is ready (e.g. `useEffect`, `mounted`, `ngAfterViewInit`) |\r\n\r\n> 💡 Pick your framework below for the full copy-paste snippet:\r\n\r\n<details>\r\n<summary><b>📦 Create React App</b></summary>\r\n\r\n### Step 1: Add CDN to `public/index.html`\r\n\r\n```html\r\n<head>\r\n  <link\r\n    rel=\"stylesheet\"\r\n    href=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.css\"\r\n  />\r\n</head>\r\n<body>\r\n  <div id=\"root\"></div>\r\n  <script src=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.js\"></script>\r\n</body>\r\n```\r\n\r\n### Step 2: Add to your layout or header component\r\n\r\nOpen an **existing** component that renders on every page — typically `src/components/Header.jsx`, `src/layouts/MainLayout.jsx`, or your root `App.jsx`. Add the snippet below to that component so the share button is consistently available across your app.\r\n\r\n```jsx\r\nimport { useEffect, useRef } from \"react\";\r\nimport { useLocation } from \"react-router-dom\"; // omit if not using React Router\r\n\r\n// ⬇️ Replace 'Header' with the name of the component where you want the\r\n// share button to appear — e.g. Navbar, MainLayout, App, etc.\r\nfunction Header() {\r\n  const shareButtonRef = useRef(null);\r\n  const initRef = useRef(false);\r\n  const { pathname } = useLocation(); // omit if not using React Router\r\n\r\n  useEffect(() => {\r\n    if (initRef.current || !window.SocialShareButton) return;\r\n\r\n    shareButtonRef.current = new window.SocialShareButton({\r\n      container: \"#share-button\",\r\n    });\r\n    initRef.current = true;\r\n\r\n    return () => {\r\n      if (shareButtonRef.current?.destroy) {\r\n        shareButtonRef.current.destroy();\r\n      }\r\n      initRef.current = false;\r\n    };\r\n  }, []);\r\n\r\n  // Keep the share URL and title in sync with the current route\r\n  useEffect(() => {\r\n    if (shareButtonRef.current) {\r\n      shareButtonRef.current.updateOptions({\r\n        url: window.location.href,\r\n        title: document.title,\r\n      });\r\n    }\r\n  }, [pathname]); // re-runs on every client-side route change\r\n\r\n  return (\r\n    <header>\r\n      <div id=\"share-button\"></div>\r\n    </header>\r\n  );\r\n}\r\n```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>▲ Next.js (App Router)</b></summary>\r\n\r\n### Step 1: Add CDN to `app/layout.tsx`\r\n\r\n```tsx\r\nimport Script from \"next/script\";\r\n\r\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\r\n  return (\r\n    <html lang=\"en\">\r\n      <head>\r\n        <link\r\n          rel=\"stylesheet\"\r\n          href=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.css\"\r\n        />\r\n      </head>\r\n      <body>\r\n        {children}\r\n        <Script\r\n          src=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.js\"\r\n          strategy=\"beforeInteractive\"\r\n        />\r\n      </body>\r\n    </html>\r\n  );\r\n}\r\n```\r\n\r\n### Step 2: Add to a Client Component (Header, Navbar, or similar)\r\n\r\nBecause `SocialShareButton` manipulates the DOM, it must run inside a **Client Component** (note the `\"use client\"` directive at the top). Add the snippet below to an existing component such as `app/components/Header.tsx` or `app/components/Navbar.tsx` — any component already included in your layout.\r\n\r\n```tsx\r\n\"use client\";\r\n\r\nimport { useEffect, useRef } from \"react\";\r\nimport { usePathname } from \"next/navigation\";\r\n\r\n// ⬇️ Replace 'Header' with the name of the component where you want the\r\n// share button to appear — e.g. Navbar, MainLayout, App, etc.\r\nexport default function Header() {\r\n  const shareButtonRef = useRef<any>(null);\r\n  const containerRef = useRef<HTMLDivElement>(null);\r\n  const initRef = useRef(false);\r\n  const pathname = usePathname();\r\n\r\n  useEffect(() => {\r\n    const initButton = () => {\r\n      if (initRef.current || !window.SocialShareButton || !containerRef.current) return;\r\n\r\n      shareButtonRef.current = new window.SocialShareButton({\r\n        container: \"#share-button\",\r\n      });\r\n      initRef.current = true;\r\n    };\r\n\r\n    if (window.SocialShareButton) {\r\n      initButton();\r\n    } else {\r\n      const checkInterval = setInterval(() => {\r\n        if (window.SocialShareButton) {\r\n          clearInterval(checkInterval);\r\n          initButton();\r\n        }\r\n      }, 100);\r\n\r\n      return () => {\r\n        clearInterval(checkInterval);\r\n        if (shareButtonRef.current?.destroy) {\r\n          shareButtonRef.current.destroy();\r\n        }\r\n        initRef.current = false;\r\n      };\r\n    }\r\n\r\n    return () => {\r\n      if (shareButtonRef.current?.destroy) {\r\n        shareButtonRef.current.destroy();\r\n      }\r\n      initRef.current = false;\r\n    };\r\n  }, []);\r\n\r\n  // Keep the share URL and title in sync with the current route\r\n  useEffect(() => {\r\n    if (shareButtonRef.current) {\r\n      shareButtonRef.current.updateOptions({\r\n        url: window.location.href,\r\n        title: document.title,\r\n      });\r\n    }\r\n  }, [pathname]); // re-runs on every client-side navigation\r\n\r\n  return (\r\n    <header>\r\n      <div id=\"share-button\" ref={containerRef}></div>\r\n    </header>\r\n  );\r\n}\r\n\r\ndeclare global {\r\n  interface Window {\r\n    SocialShareButton: any;\r\n  }\r\n}\r\n```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>📄 Next.js (Pages Router)</b></summary>\r\n\r\n### Step 1: Add CDN to `pages/_document.tsx`\r\n\r\n```tsx\r\nimport { Html, Head, Main, NextScript } from \"next/document\";\r\n\r\nexport default function Document() {\r\n  return (\r\n    <Html>\r\n      <Head>\r\n        <link\r\n          rel=\"stylesheet\"\r\n          href=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.css\"\r\n        />\r\n      </Head>\r\n      <body>\r\n        <Main />\r\n        <NextScript />\r\n        <script src=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.js\"></script>\r\n      </body>\r\n    </Html>\r\n  );\r\n}\r\n```\r\n\r\n### Step 2: Add to your Header, Navbar, or shared layout component\r\n\r\nOpen an existing component that is rendered on every page — typically `components/Header.tsx`, `components/Navbar.tsx`, or `components/Layout.tsx`. Since `_document.tsx` loads the script globally, the button is ready to initialize in any of these components.\r\n\r\n```tsx\r\nimport { useEffect, useRef } from \"react\";\r\nimport { useRouter } from \"next/router\";\r\n\r\n// ⬇️ Replace 'Header' with the name of the component where you want the\r\n// share button to appear — e.g. Navbar, MainLayout, App, etc.\r\nexport default function Header() {\r\n  const shareButtonRef = useRef<any>(null);\r\n  const containerRef = useRef<HTMLDivElement>(null);\r\n  const initRef = useRef(false);\r\n  const { pathname } = useRouter();\r\n\r\n  useEffect(() => {\r\n    const initButton = () => {\r\n      if (initRef.current || !window.SocialShareButton || !containerRef.current) return;\r\n\r\n      shareButtonRef.current = new window.SocialShareButton({\r\n        container: \"#share-button\",\r\n      });\r\n      initRef.current = true;\r\n    };\r\n\r\n    if (window.SocialShareButton) {\r\n      initButton();\r\n    } else {\r\n      const checkInterval = setInterval(() => {\r\n        if (window.SocialShareButton) {\r\n          clearInterval(checkInterval);\r\n          initButton();\r\n        }\r\n      }, 100);\r\n\r\n      return () => {\r\n        clearInterval(checkInterval);\r\n        if (shareButtonRef.current?.destroy) {\r\n          shareButtonRef.current.destroy();\r\n        }\r\n        initRef.current = false;\r\n      };\r\n    }\r\n\r\n    return () => {\r\n      if (shareButtonRef.current?.destroy) {\r\n        shareButtonRef.current.destroy();\r\n      }\r\n      initRef.current = false;\r\n    };\r\n  }, []);\r\n\r\n  // Keep the share URL and title in sync with the current route\r\n  useEffect(() => {\r\n    if (shareButtonRef.current) {\r\n      shareButtonRef.current.updateOptions({\r\n        url: window.location.href,\r\n        title: document.title,\r\n      });\r\n    }\r\n  }, [pathname]); // re-runs on every client-side navigation\r\n\r\n  return (\r\n    <header>\r\n      <div id=\"share-button\" ref={containerRef}></div>\r\n    </header>\r\n  );\r\n}\r\n\r\ndeclare global {\r\n  interface Window {\r\n    SocialShareButton: any;\r\n  }\r\n}\r\n```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>⚡ Vite / Vue / Angular</b></summary>\r\n\r\n### Step 1: Add CDN to `index.html`\r\n\r\n```html\r\n<head>\r\n  <link\r\n    rel=\"stylesheet\"\r\n    href=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.css\"\r\n  />\r\n</head>\r\n<body>\r\n  <div id=\"app\"></div>\r\n  <script src=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.3/src/social-share-button.js\"></script>\r\n</body>\r\n```\r\n\r\n### Step 2: Add a container element and initialize in your component\r\n\r\nOpen your root or layout component (e.g., `App.vue`, `app.component.html`, or `App.jsx`). Add a container `<div>` where you want the button to appear, then initialize the button after the DOM is ready:\r\n\r\n```javascript\r\n// Add <div id=\"share-button\"></div> to your component's template/HTML first,\r\n// then initialize once the DOM is ready (e.g., in mounted(), ngAfterViewInit(), or useEffect()):\r\nnew window.SocialShareButton({\r\n  container: \"#share-button\",\r\n});\r\n```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>⚛️ Preact</b></summary>\r\n\r\n### Step 1: Add CDN to `index.html`\r\n\r\n```html\r\n<head>\r\n  <link\r\n    rel=\"stylesheet\"\r\n    href=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.4/src/social-share-button.css\"\r\n  />\r\n</head>\r\n<body>\r\n  <div id=\"app\"></div>\r\n  <script src=\"https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.4/src/social-share-button.js\"></script>\r\n</body>\r\n```\r\n\r\n### Step 2: Add to a layout or header component\r\n\r\nOpen an **existing** component that renders on every page — typically `src/components/Header.jsx`, `src/components/Navbar.jsx`, or your root `App.jsx`. Add the snippet below to that component so the share button is consistently available across your app.\r\n\r\n```jsx\r\nimport { useEffect, useRef } from \"preact/hooks\";\r\n\r\n// ⬇️ Replace 'Header' with the name of the component where you want the\r\n// share button to appear — e.g. Navbar, MainLayout, App, etc.\r\nexport default function Header() {\r\n  const shareButtonRef = useRef(null);\r\n  const containerRef = useRef(null);\r\n  const initRef = useRef(false);\r\n\r\n  useEffect(() => {\r\n    if (initRef.current || !window.SocialShareButton || !containerRef.current) return;\r\n\r\n    shareButtonRef.current = new window.SocialShareButton({\r\n      container: \"#share-button\",\r\n    });\r\n    initRef.current = true;\r\n\r\n    return () => {\r\n      if (shareButtonRef.current?.destroy) {\r\n        shareButtonRef.current.destroy();\r\n      }\r\n      initRef.current = false;\r\n    };\r\n  }, []);\r\n\r\n  return (\r\n    <header>\r\n      <div id=\"share-button\" ref={containerRef}></div>\r\n    </header>\r\n  );\r\n}\r\n```\r\n\r\n</details>\r\n\r\n---\r\n\r\n## Configuration\r\n\r\n### Basic Options\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\", // Required: CSS selector or DOM element\r\n  url: \"https://example.com\", // Optional: defaults to window.location.href\r\n  title: \"Custom Title\", // Optional: defaults to document.title\r\n  buttonText: \"Share\", // Optional: button label text\r\n  buttonStyle: \"primary\", // default | primary | compact | icon-only\r\n  theme: \"dark\", // dark | light\r\n  platforms: [\"twitter\", \"linkedin\"], // Optional: defaults to all platforms\r\n});\r\n```\r\n\r\n### All Available Options\r\n\r\n| Option             | Type           | Default                | Description                                        |\r\n| ------------------ | -------------- | ---------------------- | -------------------------------------------------- |\r\n| `container`        | string/Element | -                      | **Required.** CSS selector or DOM element          |\r\n| `url`              | string         | `window.location.href` | URL to share                                       |\r\n| `title`            | string         | `document.title`       | Share title/headline                               |\r\n| `description`      | string         | `''`                   | Additional description text                        |\r\n| `hashtags`         | array          | `[]`                   | Hashtags for posts (e.g., `['js', 'webdev']`)      |\r\n| `via`              | string         | `''`                   | Twitter handle (without @)                         |\r\n| `platforms`        | array          | All platforms          | Platforms to show (see below)                      |\r\n| `buttonText`       | string         | `'Share'`              | Button label text                                  |\r\n| `buttonStyle`      | string         | `'default'`            | `default`, `primary`, `compact`, `icon-only`       |\r\n| `buttonColor`      | string         | `''`                   | Custom button background color                     |\r\n| `buttonHoverColor` | string         | `''`                   | Custom button hover color                          |\r\n| `customClass`      | string         | `''`                   | Additional CSS class for button                    |\r\n| `theme`            | string         | `'dark'`               | `dark` or `light`                                  |\r\n| `modalPosition`    | string         | `'center'`             | Modal position on screen                           |\r\n| `showButton`       | boolean        | `true`                 | Show/hide the share button                         |\r\n| `onShare`          | function       | `null`                 | Callback when user shares: `(platform, url) => {}` |\r\n| `onCopy`           | function       | `null`                 | Callback when user copies link: `(url) => {}`      |\r\n\r\n**Available Platforms:**  \r\n`whatsapp`, `facebook`, `twitter`, `linkedin`, `telegram`, `reddit`, `email`, `pinterest`, `discord`\r\n\r\n### Customize Share Message/Post Text\r\n\r\nControl the text that appears when users share to social platforms:\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  url: \"https://myproject.com\",\r\n  title: \"Check out my awesome project!\", // Main title/headline\r\n  description: \"An amazing tool for developers\", // Additional description\r\n  hashtags: [\"javascript\", \"webdev\", \"opensource\"], // Hashtags included in posts\r\n  via: \"MyProjectHandle\", // Your Twitter handle\r\n});\r\n```\r\n\r\n**How messages are customized per platform:**\r\n\r\n- **WhatsApp:** `title` + `description` + `hashtags` + link\r\n- **Facebook:** `title` + `description` + `hashtags` + link\r\n- **Twitter/X:** `title` + `description` + `hashtags` + `via` handle + link\r\n- **Telegram:** `title` + `description` + `hashtags` + link\r\n- **LinkedIn:** `title` + `description` + link\r\n- **Reddit:** `title` - `description` (used as title)\r\n- **Email:** Subject = `title`, Body = `description` + link\r\n- **Pinterest:** `title` + `description` + `hashtags` + link\r\n- **Discord:** `title` + `description` + `hashtags` + link\r\n-\r\n\r\n### Customize Button Color & Appearance\r\n\r\n**Option 1: Use Pre-built Styles** (Easiest)\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonStyle: \"primary\", // or 'default', 'compact', 'icon-only'\r\n});\r\n```\r\n\r\n**Option 2: Programmatic Color Customization** (Recommended)\r\n\r\nPass `buttonColor` and `buttonHoverColor` to match your project's color scheme:\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonColor: \"#ff6b6b\", // Button background color\r\n  buttonHoverColor: \"#ff5252\", // Hover state color\r\n});\r\n```\r\n\r\n**Option 3: CSS Class Customization** (Advanced)\r\n\r\nFor more complex styling, use a custom CSS class:\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonStyle: \"primary\",\r\n  customClass: \"my-custom-button\",\r\n});\r\n```\r\n\r\nThen in your CSS file:\r\n\r\n```css\r\n/* Override the button background color */\r\n.my-custom-button.social-share-btn {\r\n  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\r\n  color: white;\r\n}\r\n\r\n/* Customize hover state */\r\n.my-custom-button.social-share-btn:hover {\r\n  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);\r\n}\r\n```\r\n\r\n**Color Examples:**\r\n\r\n```jsx\r\n// Material Design Red\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonColor: \"#f44336\",\r\n  buttonHoverColor: \"#da190b\",\r\n});\r\n\r\n// Tailwind Blue\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonColor: \"#3b82f6\",\r\n  buttonHoverColor: \"#2563eb\",\r\n});\r\n\r\n// Custom Brand Color\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonColor: \"#your-brand-color\",\r\n  buttonHoverColor: \"#your-brand-color-dark\",\r\n});\r\n```\r\n\r\n### Button Styles\r\n\r\n| Style       | Description                        |\r\n| ----------- | ---------------------------------- |\r\n| `default`   | Standard button with icon and text |\r\n| `primary`   | Gradient button (recommended)      |\r\n| `compact`   | Smaller size for tight spaces      |\r\n| `icon-only` | Icon without text                  |\r\n\r\n### Callbacks\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  onShare: (platform, url) => {\r\n    console.log(`Shared on ${platform}: ${url}`);\r\n  },\r\n  onCopy: (url) => {\r\n    console.log(\"Link copied:\", url);\r\n  },\r\n});\r\n```\r\n\r\n---\r\n\r\n## Advanced Usage\r\n\r\n### Using npm Package\r\n\r\n```javascript\r\nimport SocialShareButton from \"@aossie-org/social-share-button\";\r\nimport \"@aossie-org/social-share-button/src/social-share-button.css\";\r\n\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n});\r\n```\r\n\r\n### React Wrapper Component (Optional)\r\n\r\nIf you want a reusable React component, copy `src/social-share-button-react.jsx` to your project:\r\n\r\n```jsx\r\nimport { SocialShareButton } from \"./components/SocialShareButton\";\r\n\r\nfunction App() {\r\n  return <SocialShareButton platforms={[\"twitter\", \"linkedin\"]} />;\r\n}\r\n```\r\n\r\n### Update URL Dynamically (SPA)\r\n\r\n```jsx\r\n// Next.js App Router: import { usePathname } from \"next/navigation\";\r\n// Next.js Pages Router: import { useRouter } from \"next/router\";\r\n// React Router: import { useLocation } from \"react-router-dom\";\r\n\r\nconst shareButton = useRef(null);\r\n// Get the current pathname from your router, e.g.:\r\n// const pathname = usePathname();          // Next.js App Router\r\n// const { pathname } = useRouter();        // Next.js Pages Router\r\n// const { pathname } = useLocation();      // React Router\r\n\r\nuseEffect(() => {\r\n  shareButton.current = new window.SocialShareButton({\r\n    container: \"#share-button\",\r\n  });\r\n}, []);\r\n\r\nuseEffect(() => {\r\n  if (shareButton.current) {\r\n    shareButton.current.updateOptions({\r\n      url: window.location.href,\r\n      title: document.title,\r\n    });\r\n  }\r\n}, [pathname]); // re-runs on every client-side route change\r\n```\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n<details>\r\n<summary><b>Multiple buttons appearing</b></summary>\r\n\r\n**Cause:** Component re-renders creating duplicate instances\r\n\r\n**Solution:** Use `useRef` to track initialization (already in examples above)\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>Button not appearing</b></summary>\r\n\r\n**Cause:** Script loads after component renders\r\n\r\n**Solution:** Add null check:\r\n\r\n```jsx\r\nif (window.SocialShareButton) {\r\n  new window.SocialShareButton({ container: \"#share-button\" });\r\n}\r\n```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>Modal not opening</b></summary>\r\n\r\n**Cause:** CSS not loaded or ID mismatch\r\n\r\n**Solution:**\r\n\r\n- Verify CSS CDN link in `<head>`\r\n- Match container ID: `container: '#share-button'` = `<div id=\"share-button\">`\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>TypeError: SocialShareButton is not a constructor</b></summary>\r\n\r\n**Cause:** CDN script not loaded yet\r\n\r\n**Solution:** Use interval polling (see Next.js example above)\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>URL not updating on navigation</b></summary>\r\n\r\n**Cause:** Component initialized once, doesn't track routes\r\n\r\n**Solution:** Use `updateOptions()` method (see Advanced Usage above)\r\n\r\n</details>\r\n\r\n---\r\n\r\n## Examples\r\n\r\n### Mobile Menu\r\n\r\n```jsx\r\n<nav>\r\n  <div id=\"share-button\"></div>\r\n</nav>\r\n```\r\n\r\n### Custom Platforms\r\n\r\n```jsx\r\n// Professional networks only\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  platforms: [\"linkedin\", \"twitter\", \"email\"],\r\n});\r\n\r\n// Messaging apps only\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  platforms: [\"whatsapp\", \"telegram\"],\r\n});\r\n```\r\n\r\n### Custom Styling\r\n\r\n```jsx\r\nnew SocialShareButton({\r\n  container: \"#share-button\",\r\n  buttonStyle: \"icon-only\",\r\n  theme: \"light\",\r\n});\r\n```\r\n\r\n---\r\n\r\n## Demo\r\n\r\nOpen `index.html` in your browser to see all features.\r\nTutorial: https://youtu.be/cLJaT-8rEvQ?si=CLipA0Db4WL0EqKM\r\n\r\n---\r\n\r\n## Contributing\r\n\r\nWe welcome contributions of all kinds! To contribute:\r\n\r\n1. Fork the repository and create your feature branch (`git checkout -b feature/AmazingFeature`).\r\n2. Commit your changes (`git commit -m 'Add some AmazingFeature'`).\r\n3. Run code quality checks:\r\n   - `npm run lint` - Check for code issues\r\n   - `npm run format:check` - Check code formatting\r\n   - `npm run format` - Auto-format code\r\n4. Test your changes by opening `index.html` in your browser to verify functionality.\r\n5. Push your branch (`git push origin feature/AmazingFeature`).\r\n6. Open a Pull Request for review.\r\n\r\nIf you encounter bugs, need help, or have feature requests:\r\n\r\n- Please open an issue in this repository providing detailed information.\r\n- Describe the problem clearly and include any relevant logs or screenshots.\r\n\r\nWe appreciate your feedback and contributions!\r\n\r\nThis project is licensed under the GNU General Public License v3.0.\r\nSee the [LICENSE](LICENSE) file for details.\r\n\r\n---\r\n\r\n## 💪 Thanks To All Contributors\r\n\r\nThanks a lot for spending your time helping SocialShareButton grow. Keep rocking 🥂\r\n\r\n[![Contributors](https://contrib.rocks/image?repo=AOSSIE-Org/SocialShareButton)](https://github.com/AOSSIE-Org/SocialShareButton/graphs/contributors)\r\n\r\n© 2025 AOSSIE\r\n","readmeFilename":"README.md","_rev":"1-7cf27a7367060b8c27384b05b2228f90"}