Links
openLink
To open a link in an external browser or using Instant View, use the openLink
method. You can also pass an optional second argument, an object with optional properties tryBrowser: OpenLinkBrowser (string)
and tryInstantView: boolean
.
ts
import { openLink } from '@telegram-apps/sdk';
if (openLink.isAvailable()) {
openLink('https://telegram.org', {
tryBrowser: 'chrome',
tryInstantView: true,
});
}
ts
import { openLink } from '@telegram-apps/sdk';
openLink.ifAvailable('https://telegram.org', {
tryBrowser: 'chrome',
tryInstantView: true,
});
openTelegramLink
To open a Telegram link with predefined behavior, use the openTelegramLink
method. This method allows you to apply the native behavior as described in the Deep Links documentation.
ts
import { openTelegramLink } from '@telegram-apps/sdk';
if (openTelegramLink.isAvailable()) {
openTelegramLink('https://t.me/heyqbnk');
}
ts
import { openTelegramLink } from '@telegram-apps/sdk';
openTelegramLink.ifAvailable('https://t.me/heyqbnk');
shareURL
To share a URL with another user, channel, or group, use the shareURL
method.
ts
import { shareURL } from '@telegram-apps/sdk';
if (shareURL.isAvailable()) {
shareURL('https://t.me/heyqbnk', 'Check out this cool group!');
}
ts
import { shareURL } from '@telegram-apps/sdk';
shareURL.ifAvailable(
'https://t.me/heyqbnk',
'Check out this cool group!',
);