Primitives to help with sharing content on social media and beyond.
| Stage | Category | Version | Last Updated | Demo |
|---|---|---|---|---|
| 3 | Utilities | 4.0.0-next.4 (next) | Aug 12, 2026 | Demo → |
npm i @solid-primitives/share@nextPrimitives for supporting sharing of resources on social media and beyond.
createSocialShare- A primitive for sharing on social media and beyond.makeWebShare- A simple non-reactive base primitive for the Web Share API.createWebShare- A reactive action-based primitive for the Web Share API with status tracking.
createSocialShare
How to use it
import { createSocialShare, BLUESKY } from "@solid-primitives/share";
const { share, close, isSharing } = createSocialShare(() => ({ title: "SolidJS.com", url: "https://www.solidjs.com", description: "Simple and well-behaved reactivity!",}));
share(BLUESKY);Definition
function createSocialShare( options: Accessor<{ network?: Network; url: string; title: string; description: string; quote?: string; hashtags?: string; twitterUser?: string; media?: string; tag?: string; popup?: SharePopupOptions; }>, controller: Window = window,): SocialShareResult;
type SocialShareResult = { share: (network?: Network) => void; close: () => void; isSharing: Accessor<boolean>;};Network List
The following are a list of supported networks that may be imported from the share package.
| Network | url | title | description | Extras/Comments |
|---|---|---|---|---|
| Bluesky | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Buffer | :heavy_check_mark: | :heavy_check_mark: | :x: | |
| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | ||
| EverNote | :heavy_check_mark: | :heavy_check_mark: | :x: | |
| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | hashtags A list of comma-separated hashtags, only the first one will be used.quote Facebook quote. | |
| :heavy_check_mark: | :heavy_check_mark: | :x: | ||
| HackerNews | :heavy_check_mark: | :heavy_check_mark: | :x: | |
| InstaPaper | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Line | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| :heavy_check_mark: | :x: | :x: | ||
| Messenger | :heavy_check_mark: | :x: | :x: | |
| Odnoklassniki | :heavy_check_mark: | :heavy_check_mark: | :x: | |
| :heavy_check_mark: | :heavy_check_mark: | :x: | media URL of an image describing the content. | |
| :heavy_check_mark: | :heavy_check_mark: | :x: | ||
| Quora | :heavy_check_mark: | :heavy_check_mark: | :x: | |
| :heavy_check_mark: | :heavy_check_mark: | :x: | ||
| Skype | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| SMS | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Telegram | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Tumblr | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| :heavy_check_mark: | :heavy_check_mark: | :x: | hashtags A list of comma-separated hashtags.twitterUser Twitter user to mention. | |
| Viber | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| VK | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | media URL of an image describing the content. |
| Warpcast | :heavy_check_mark: | :heavy_check_mark: | :x: | Farcaster decentralized social network. |
| :heavy_check_mark: | :heavy_check_mark: | :x: | media URL of an image describing the content. | |
| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | ||
| Wordpress | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | media URL of an image describing the content. |
| X | :heavy_check_mark: | :heavy_check_mark: | :x: | hashtags A list of comma-separated hashtags.twitterUser X user to mention. |
| :heavy_check_mark: | :heavy_check_mark: | :x: | ||
| Yammer | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
Deprecated:
STUMBLEUPON(shut down 2018) andMESSANGER(typo — useMESSENGER) are still exported for backwards compatibility but will be removed in a future version.
For the networks Bluesky, Line, Skype, SMS, Telegram, Viber, WhatsApp, and Yammer the shared content is a string of the form: "$title $url $description".
You can also provide a custom network by formatting a URL string with the following replacement markers:
@u: URL@t: Title@d: Description@q: Quote@h: Hashtags@m: Media@tu: X/Twitter user mention
Example:
const x: Network = "https://www.x.com/intent/tweet?text=@t&url=@u&hashtags=@h@tu";Acknowledgements
A portion of this primitive was built from https://github.com/nicolasbeauvais/vue-social-sharing/blob/master/src/share-network.js.
makeWebShare
A simple non-reactive base primitive wrapping the Web Share API. Returns a share function that rejects with a descriptive message if the browser does not support sharing or file sharing.
How to use it
import { makeWebShare } from "@solid-primitives/share";
const share = makeWebShare();
try { await share({ url: "https://solidjs.com" });} catch (e) { console.error(e);}createWebShare
A reactive, action-based primitive for the Web Share API. Call share imperatively on a user gesture and observe the result via reactive accessors.
How to use it
import { createWebShare } from "@solid-primitives/share";
const { share, pending, status, message } = createWebShare();<button disabled={pending()} onClick={() => share({ url: location.href, title: document.title })}> {pending() ? "Sharing..." : "Share"}</button>
<Show when={status() === false}> <p>Share failed: {message()}</p></Show>Definition
function createWebShare(): WebShareResult;
type WebShareResult = { /** Imperatively trigger the Web Share API with the provided data. */ share: (data: ShareData) => Promise<void>; /** True while the share dialog is open / the promise is pending. */ pending: Accessor<boolean>; /** True on success, false on failure, undefined before first share. */ status: Accessor<boolean | undefined>; /** The error message if the share failed, otherwise undefined. */ message: Accessor<string | undefined>;};Changelog
See CHANGELOG.md