> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# QR / barcode scanner

> Scan QR codes and barcodes with the device camera from your website, using the JavaScript Bridge and open-source scanning libraries.

Add QR code and barcode scanning to your mobile app using the device camera. Ideal for use cases such as:

* In-store retail shopping
* Warehouse and inventory management
* Data center asset tracking

The Median QR/Barcode Scanner plugin is built on top of customized, open-source libraries and offers full functionality without licensing fees or usage limits.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## Underlying open-source technologies

**Android**: [ZXing (Zebra Crossing) library](https://github.com/zxing/zxing)

**iOS**: [hyperoslo BarcodeScanner library](https://github.com/hyperoslo/BarcodeScanner)

## UI example

| iOS | Android |
| :-: | :-: |
| ![QR code scanner on iOS](https://mintcdn.com/median-co/7LCOHMhgIef7ewYE/images/docs/5649c1d-Apple-QR.png?fit=max\&auto=format\&n=7LCOHMhgIef7ewYE\&q=85\&s=e66edaa9b34dd0520bd283e3d5c57004) | ![QR code scanner on Android](https://mintcdn.com/median-co/7LCOHMhgIef7ewYE/images/docs/7bb3e13-Android-QR_1.png?fit=max\&auto=format\&n=7LCOHMhgIef7ewYE\&q=85\&s=31b4ed7d2df6366b33219468fb0b0a35) |

## Implementation guide

*Once the QR/Barcode Scanner plugin has been added to your app, you may use the following Median JavaScript Bridge commands to access its functionality.*

### Start a QR/barcode scan

Use `median.barcode.scan()` to trigger the native scanner. By default, all supported formats trigger a scan. You can pass a `formats` array to restrict which code types can trigger a scan. If `formats` is omitted or empty, all supported types are scanned.\
The method supports both callback and Promise-based approaches:

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Callback example
median.barcode.scan({
  formats: ['QR_CODE', 'EAN_13'],
  callback: process_barcode
});

function process_barcode(data) {
  if (data.success) {
    console.log('Got barcode: ' + data.code);
  }
}

// Promise example
median.barcode.scan({ formats: ['QR_CODE'] }).then(function (data) {
  if (data.success) {
    console.log('Got barcode: ' + data.code);
  }
});

// Scan all supported formats (default)
median.barcode.scan().then(function (data) {
  if (data.success) {
    console.log('Got barcode: ' + data.code);
  }
});
```

The native scanner UI will launch within your app. Upon scan completion, focus will return to the webview where an object in the format below will be returned.

```json JSON theme={null}
{
  success: true,      // boolean — true if a code was scanned
  type: "STRING",     // Symbology (e.g. 'qr', 'code128')
  code: "STRING",     // The actual scanned value
  error: "STRING"     // Error message if unsuccessful
}
```

[Learn more about using promises and the Median JavaScript Bridge](https://docs.median.co/docs/javascript-bridge.md#promises).

**Supported formats**

* **QR Codes (2D):** QR\_CODE, DATA\_MATRIX, AZTEC, PDF\_417
* **Barcodes (1D):** EAN\_13, EAN\_8, UPC\_A, UPC\_E, CODE\_39, CODE\_93, CODE\_128, ITF, CODABAR

### Customizing the scanner prompt

You can customize the message shown to users during scanning by setting a prompt in the plugin settings. To do this, go to *Native Plugins > QR / Barcode Scanner*, as shown below.

![QR / Barcode Scanner - Custom Prompt Message](https://mintcdn.com/median-co/7LCOHMhgIef7ewYE/images/docs/73d82f57ef12af3723c6a0c713248a84b733aa8ff6ee93bd417cf4516633284a-Screenshot_2025-07-04_at_14.29.42.png?fit=max\&auto=format\&n=7LCOHMhgIef7ewYE\&q=85\&s=d3dd579f1921f8ab55cf01cff352798a)

### Set custom prompt message at runtime

You can also dynamically set the prompt message in-app using the `setPrompt()` method:

Median JavaScript Bridge

```javascript JavaScript  theme={null}
median.barcode.setPrompt('Align the QR code or barcode within the frame to scan automatically'); 
```


## Related topics

- [Scanning](https://docs.median.co/docs/scanning.md)
- [Salesforce LWC component deployment and reference](https://docs.median.co/docs/salesforce-lwc-components.md)
- [Native datastore offline](https://docs.median.co/docs/native-datastore-offline.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.