Skip to content


The component which provides the QR scanner functionality.


To initialize the component, use the initQRScanner function:

import { initQRScanner } from '@tma.js/sdk';

const [qrScanner] = initQRScanner();

Opening and Closing

To open the QR scanner, the developer should use the open method:

typescript'Scan QR code').then((content) => {
  // Output: 'some-data=22l&app=93...'
console.log(scanner.isOpened); // true

As a result, the method returns a promise that will be resolved in case some QR was scanned. It may also resolve null if the scanner was closed.

It is allowed to pass an object with optional properties text and capture responsible for displaying a text in QR scanner and determining if scanned QR should be captured and promise should be fulfilled.

  text: 'Scan QR code',
  capture({ data }) {
    // Capture QRs contanining Telegram user link.
    return data.startsWith('');
}).then((qr) => {
  // May be something like '' or null.

To close the scanner, use the close method:

console.log(scanner.isOpened); // false


List of events, which could be tracked:

EventListenerTriggered when
change() => voidSomething in component changed
change:isOpened(value: boolean) => voidisOpened property changed

Methods Support

List of methods, which could be used in support checks: open and close

Released under the MIT License.