Skip to main content

@rtorcato/browser-common / webshare

webshare

Functions​

isWebShareAvailable()​

isWebShareAvailable(): boolean

Defined in: webshare/index.ts:9

Checks if the Web Share API is available in the current browser.

Example​

import { isWebShareAvailable } from '@rtorcato/browser-common/webshare'
if (isWebShareAvailable()) showShareButton()

Returns​

boolean


share()​

share(data): Promise<void>

Defined in: webshare/index.ts:23

Shares data using the Web Share API.

Example​

import { share } from '@rtorcato/browser-common/webshare'
await share({ title: 'Look', url: 'https://example.com' })

Parameters​

data​

ShareData

The data to share (title, text, url, files).

Returns​

Promise<void>

A promise that resolves if sharing was successful.


isFileShareAvailable()​

isFileShareAvailable(): boolean

Defined in: webshare/index.ts:38

Checks if the Web Share API supports sharing files.

Example​

import { isFileShareAvailable } from '@rtorcato/browser-common/webshare'
if (isFileShareAvailable()) showShareFilesButton()

Returns​

boolean