Skip to main content

share

Opens the system share sheet with a text message. The user can then send the content through any app they choose — a messenger, email, notes, and so on.

Signature

import { share } from '@apps-in-toss/web-framework';

declare function share(message: { message: string }): Promise<void>;

Parameters

NameTypeRequiredDescription
message.messagestringThe text to share. URLs in the message are typically detected and rendered as previews by the receiving app.

Returns

  • Promise<void> — resolves once the share sheet opens. Rejecting by cancelling does not cause a rejection.
  • In the devtools mock, navigator.share is used when available. In unsupported environments, the message is logged to the console.

Permission

No permission required.

Examples

Minimal

import { share } from '@apps-in-toss/web-framework';

await share({ message: 'Check this out! https://example.com' });

Realistic — invite code share button

import { getTossShareLink, share } from '@apps-in-toss/web-framework';

export function InviteButton({ inviteCode }: { inviteCode: string }) {
async function handleShare() {
const link = await getTossShareLink(`/invite/${inviteCode}`);
await share({
message: `Join me! Invite code: ${inviteCode}\n${link}`,
});
}

return (
<button type="button" onClick={handleShare}>
Invite a friend
</button>
);
}

Try it live

Open the Navigation page in sdk-example and run the share card.

Open in sdk-example

External references