π― Direction
SocialShareButton is a lightweight, zero-dependency, framework-agnostic social sharing component. Remix is a full-stack React framework built on web standards with a strong SSR-first model. Since Remix always server-renders, the library must only initialize inside a useEffect hook and all browser APIs must be guarded. Unlike Next.js App Router, Remix has no 'use client' directive β client-side code runs exclusively inside useEffect.
πΉ See the button in action: https://youtu.be/cLJaT-8rEvQ?si=CLipA0Db4WL0EqKM
π Files to Create / Modify
β
New File: src/social-share-button-remix.jsx
A Remix-compatible React component that safely wraps the vanilla JS library:
import { useEffect, useRef } from 'react';
export default function SocialShareButton({
url = '',
title = '',
description = '',
hashtags = [],
via = '',
platforms = ['whatsapp', 'facebook', 'twitter', 'linkedin', 'telegram', 'reddit'],
theme = 'dark',
buttonText = 'Share',
customClass = '',
onShare = null,
onCopy = null,
buttonStyle = 'default',
modalPosition = 'center'
}) {
const containerRef = useRef(null);
const shareButtonRef = useRef(null);
useEffect(() => {
// SSR guard β Remix always server-renders; browser APIs only available here
if (typeof window !== 'undefined' && window.SocialShareButton) {
shareButtonRef.current = new window.SocialShareButton({
container: containerRef.current,
url: url || window.location.href,
title: title || document.title,
description, hashtags, via, platforms,
theme, buttonText, customClass,
onShare, onCopy, buttonStyle, modalPosition
});
}
return () => {
if (shareButtonRef.current) {
shareButtonRef.current.destroy();
shareButtonRef.current = null;
}
};
}, []);
useEffect(() => {
if (shareButtonRef.current) {
shareButtonRef.current.updateOptions({
url, title, description, hashtags, via, platforms,
theme, buttonText, customClass, onShare, onCopy,
buttonStyle, modalPosition
});
}
}, [url, title, description, hashtags, via, platforms,
theme, buttonText, customClass, onShare, onCopy,
buttonStyle, modalPosition]);
return <div ref={containerRef}></div>;
}
β
Existing File: index.html β Add Remix Integration Section
Add a new section with:
- Section heading:
πΈ Remix Integration
- Step 1: Include CSS via
links export and JS via CDN <script> in root.tsx
- Step 2: Import and use the component in a Remix route
Example code snippet to display:
// app/routes/_index.tsx
import SocialShareButton from '~/components/social-share-button-remix';
export default function Index() {
return (
<SocialShareButton
url="https://your-website.com"
title="Check this out!"
description="An amazing website"
theme="dark"
buttonText="Share"
/>
);
}
β
Acceptance Criteria
β οΈ Planned β Not Final
This issue represents a planned enhancement and is not guaranteed to be implemented. It may be dropped if it does not align with the repository's direction. Before opening a pull request, please discuss with the maintainers in this issue thread.
π― Direction
SocialShareButton is a lightweight, zero-dependency, framework-agnostic social sharing component. Remix is a full-stack React framework built on web standards with a strong SSR-first model. Since Remix always server-renders, the library must only initialize inside a
useEffecthook and all browser APIs must be guarded. Unlike Next.js App Router, Remix has no'use client'directive β client-side code runs exclusively insideuseEffect.πΉ See the button in action: https://youtu.be/cLJaT-8rEvQ?si=CLipA0Db4WL0EqKM
π Files to Create / Modify
β New File:
src/social-share-button-remix.jsxA Remix-compatible React component that safely wraps the vanilla JS library:
β Existing File:
index.htmlβ Add Remix Integration SectionAdd a new section with:
πΈ Remix Integrationlinksexport and JS via CDN<script>inroot.tsxExample code snippet to display:
β Acceptance Criteria
src/social-share-button-remix.jsxcreated using React hooks compatible with RemixuseEffectwith SSR guard (typeof window !== 'undefined')destroy()called inuseEffectreturn functionuseEffectcallsupdateOptions()on prop changesindex.htmlupdated with a Remix section containing install + usage code snippetsindex.html