useWebShare

Hook

Progressive-enhancement hook for the Web Share API. Exposes share(), canShare(), isSupported, isLoading, and error. Falls back gracefully on unsupported platforms.

core/use-web-share

Installation

1 · Add registry to components.json

2 · Install component

Examples

Share button

Uses the native OS share sheet where supported.

API Reference

PropTypeDescription
isSupported
booleanWhether Web Share API is available.
isLoading
booleanTrue while a share dialog is open.
share
(data: WebShareData) => Promise<boolean>Trigger native share.
canShare
(data: WebShareData) => booleanCheck if specific data can be shared.
error
string | nullError message if share() throws.
clearError
() => voidReset the error state.