createShare
Category Browser
Invokes the native sharing mechanism of the device to share data such as text, URLs, or files.
The available share targets depend on the device, but might include the clipboard, contacts and email applications, websites, Bluetooth, etc.
Demo
Web share is not supported in your browser :(
Usage
IMPORTANT
To prevent abuse, it must be triggered off a UI event like a button click and cannot be launched at arbitrary points by a script.
import { createShare } from '@sv-use/core';
const share = createShare({
title: 'SvelteUse',
text: 'SvelteUse is awesome !',
url: 'https://sv-use.org'
});
Type Definitions
import { type ConfigurableNavigator } from '../__internal__/configurable.js';
import type { MaybeGetter } from '../__internal__/types.js';
type CreateShareData = {
title?: MaybeGetter<string>;
files?: MaybeGetter<File[]>;
text?: MaybeGetter<string>;
url?: MaybeGetter<string>;
};
type CreateShareOptions = ConfigurableNavigator;
type CreateShareReturn = {
readonly isSupported: boolean;
share(): Promise<void>;
};
/**
* Invokes the native sharing mechanism of the device to share data such as text, URLs, or files.
* @param data The data to share.
* @param options Additional options to customize the behavior.
* @see https://svelte-librarian.github.io/sv-use/docs/core/create-share
*/
export declare function createShare(data: CreateShareData, options?: CreateShareOptions): CreateShareReturn;
export {};