Skip to main content

setClipboardText

Copies an arbitrary string to the user's clipboard. Useful for one-tap copy UX — invite codes, shareable links, receipt numbers.

Unofficial docs

This page is community-written. The SDK behavior itself is defined by the upstream @apps-in-toss/web-framework release.

Signature

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

declare function setClipboardText(text: string): Promise<void>;

Parameters

NameTypeRequiredDescription
textstringThe string to copy. Empty strings are allowed but not recommended from a UX perspective.

Returns

  • Promise<void> — resolves after the copy completes.
  • Permission-denied failures are covered in the "Permission" section. On web, navigator.clipboard.writeText can also reject for non-permission reasons, so wrapping in try/catch is always recommended.

Permission

Requires the clipboard permission. The call fails only when the status is explicitly denied — wrap in try/catch. notDetermined lets the call through, but prompting the dialog first is the safer flow. See Guides — Permissions pattern for the full flow.

The callable exposes permission helpers:

const status = await setClipboardText.getPermission();
// 'allowed' | 'denied' | 'notDetermined'

if (status !== 'allowed') {
await setClipboardText.openPermissionDialog();
}

Examples

Minimal

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

async function copyInviteCode() {
await setClipboardText('AIT-2026-HELLO');
}

Realistic — copy with user feedback

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

// `showAppToast` is NOT provided by the SDK — substitute your app's own
// toast / snackbar component.
declare function showAppToast(message: string): void;

async function copyWithFeedback(value: string) {
try {
await setClipboardText(value);
showAppToast('Copied to clipboard');
} catch (error) {
showAppToast('Copy failed — please try again.');
console.error(error);
}
}

Try it live

Run the API in sdk-example and inspect the result.

Open in sdk-example
  • (coming soon) Recipes — copy/paste UX patterns

External references