π― Direction
SocialShareButton is a lightweight, zero-dependency, framework-agnostic social sharing component. The goal of this issue is to extend first-class support to SvelteKit, which shares the same philosophy: minimal runtime overhead, compiles to pure JS. Since SvelteKit supports SSR (Server-Side Rendering), the wrapper must guard all browser APIs with typeof window !== 'undefined' checks.
πΉ See the button in action: https://youtu.be/cLJaT-8rEvQ?si=CLipA0Db4WL0EqKM
π Files to Create / Modify
β
New File: src/social-share-button-svelte.svelte
A Svelte component that wraps the core vanilla JS library, following the same pattern as src/social-share-button-react.jsx:
<script>
import { onMount, onDestroy } from 'svelte';
export let url = '';
export let title = '';
export let description = '';
export let hashtags = [];
export let via = '';
export let platforms = ['whatsapp', 'facebook', 'twitter', 'linkedin', 'telegram', 'reddit'];
export let theme = 'dark';
export let buttonText = 'Share';
export let customClass = '';
export let onShare = null;
export let onCopy = null;
export let buttonStyle = 'default';
export let modalPosition = 'center';
let container;
let shareButton;
onMount(() => {
// SSR guard β SvelteKit pre-renders on the server
if (typeof window !== 'undefined' && window.SocialShareButton) {
shareButton = new window.SocialShareButton({
container,
url: url || window.location.href,
title: title || document.title,
description,
hashtags,
via,
platforms,
theme,
buttonText,
customClass,
onShare,
onCopy,
buttonStyle,
modalPosition
});
}
});
onDestroy(() => {
if (shareButton) {
shareButton.destroy();
shareButton = null;
}
});
// Reactive update when props change (e.g. SvelteKit route transitions)
$: if (shareButton) {
shareButton.updateOptions({
url, title, description, hashtags, via,
platforms, theme, buttonText, customClass,
onShare, onCopy, buttonStyle, modalPosition
});
}
</script>
<div bind:this={container}></div>
β
Existing File: index.html β Add SvelteKit Integration Section
Mirror the existing βοΈ React Integration section. Add a new section block with:
- Section heading:
π SvelteKit Integration
- Step 1: Include CSS and JS via CDN (same as Quick Start)
- Step 2: Import and use the
SocialShareButton.svelte component
- Step 3: Show usage inside a
+page.svelte file with props
Example code snippet to display in the demo section:
<!-- +page.svelte -->
<script>
import SocialShareButton from 'social-share-button-svelte';
<\/script>
<SocialShareButton
url="https://your-website.com"
title="Check this out!"
description="An amazing website"
theme="dark"
buttonText="Share"
/>
β
Acceptance Criteria
π― Direction
SocialShareButton is a lightweight, zero-dependency, framework-agnostic social sharing component. The goal of this issue is to extend first-class support to SvelteKit, which shares the same philosophy: minimal runtime overhead, compiles to pure JS. Since SvelteKit supports SSR (Server-Side Rendering), the wrapper must guard all browser APIs with
typeof window !== 'undefined'checks.πΉ See the button in action: https://youtu.be/cLJaT-8rEvQ?si=CLipA0Db4WL0EqKM
π Files to Create / Modify
β New File:
src/social-share-button-svelte.svelteA Svelte component that wraps the core vanilla JS library, following the same pattern as
src/social-share-button-react.jsx:β Existing File:
index.htmlβ Add SvelteKit Integration SectionMirror the existing
βοΈ React Integrationsection. Add a new section block with:π SvelteKit IntegrationSocialShareButton.sveltecomponent+page.sveltefile with propsExample code snippet to display in the demo section:
β Acceptance Criteria
src/social-share-button-svelte.sveltecreated following the React wrapper patterntypeof window !== 'undefined') present on all browser API usagesonMountused for initialization,onDestroycallsdestroy()to prevent memory leaks$:) callsupdateOptions()on prop changesindex.htmlupdated with a SvelteKit section containing install + usage code snippetsindex.html