useSocialShare

A custom hook for generating social media share URLs. This hook formats the shared URL based on the specified social media platform and supported parameters.

Confirm the supported parameters for each social media platform according to the reference table.

Usage

import { useSocialShare } from 'social-hooks';

const Demo = () => {
  const { twitter } = useSocialShare({
    url: 'https://google.com',
  });

  return (
    <div>
      Shareable twitter url: {twitter}.
     {/*  https://twitter.com/intent/tweet?url=https%3A%2F%2Fgoogle.com */}
    </div>
  );
};

Reference

Prop
Description
Supports

text string

Text content to be shared.

"linkedin", "twitter", "whatsapp", "pinterest", "odnoklassniki", "reddit", "tumblr", "mailru"

url string

URL to be shared.

"linkedin", "twitter", "pinterest", "facebook", "telegram", "vkontakte", "odnoklassniki", "reddit", "tumblr"

imageUrl string

Image URL to be shared.

"pinterest", "mailru"

description string

Description to be shared

"tumblr", "mailru"

Last updated