New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-use-web-share

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-web-share

A custom react hook for triggering the native web share dialog

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

useWebShare

code style: prettier

A custom react hook for triggering the native web share dialog in supported browsers

Demo

Usage

npm install react-use-web-share
const { loading, isSupported, share } = useWebShare();

function onClick() {
  share();
}

See example directory for full example.

Parameters

Parameterdescriptiondefaultrequired
onSuccesscalled on successfully sharing the content() => {}false
onErrorcalled when caught error from navigator share content() => {}false

Returns

NameTypeDescription
loadingbooleanLoading state
isSupportedbooleanDetects whether the feature is supported in user's browser. Can be used to show the fallback
sharefunctioncan be called to trigger the native share popup

share

This is the function that triggers the native share dialog in browser.

This takes an object as argument.

Namedescriptiondefault
titletitle of shared itemdocument.title
texttext of shared item
urlurl to be sharedcanonical url if present, otherwise current url

Contributing

  • Install dependencies
npm install
  • Run dev for lib
npm run dev
  • Run demo
npm start

Keywords

react

FAQs

Package last updated on 26 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts