---
url: https://polaris-vue-elements.dev/app-bridge/types/device-and-platform-integration.md
description: >-
  Types of the App Bridge device and platform integration APIs in
  @shopify/app-bridge-types, for Vue 3: their members and the types only they
  use.
---

# Device and platform integration {#device-and-platform-integration}

> **Beta:** These App Bridge components are new, and their API may change in a minor release while in beta. Their behaviour is checked in a live Shopify admin by a local E2E suite. If something doesn't work, please [open an issue](https://github.com/HQCuong/polaris-vue/issues).

The APIs Shopify lists under device and platform integration, and the types only they use. On this page: [`PosApi`](#posapi), [`ScannerApi`](#scannerapi), [`WebVitalsApi`](#webvitalsapi).

## `PosApi` {#posapi}

`cart: PosCart`

Provides methods to read and modify the current POS cart, including line items, discounts, customers, and properties.

`close: PosClose`

Closes the app and returns to the POS screen.

`device: PosDevice`

Returns information about the POS device, including its name and serial number. Rejects when the host does not answer, or answers without a device.

`location: PosLocation`

Returns information about the current POS location, including its ID, name, address, and status. Rejects when the host does not answer, or answers without a location.

Used in: [useAppBridge()](/app-bridge/use-app-bridge), [`ShopifyGlobal`](/app-bridge/types/#shopifyglobal)

### `PosCart` {#poscart}

```ts
type PosCart = Required<_PosCart>;
```

References: [`_PosCart`](#_poscart)
Used in: [`PosApi`](#posapi)

### `PosClose` {#posclose}

```ts
type PosClose = () => Promise<void>;
```

Used in: [`PosApi`](#posapi)

### `PosDevice` {#posdevice}

```ts
type PosDevice = () => Promise<Device>;
```

References: [`Device`](#device)
Used in: [`PosApi`](#posapi)

### `PosLocation` {#poslocation}

```ts
type PosLocation = () => Promise<Location>;
```

References: [`Location`](#location)
Used in: [`PosApi`](#posapi)

### `_PosCart` {#\_poscart}

`fetch?(): Promise<Cart>`

Fetch the current cart.

`subscribe?(onSubscribe: CartSubscriber): Unsubscribe`

Subscribe the cart changes.

`setCustomer?(customer: Customer): Promise<void>`

Add a new or existing customer to the cart.

`removeCustomer?(): Promise<void>`

Remove the current customer from the cart.

`addAddress?(address: Address): Promise<void>`

Add a new address to a customer.

`updateAddress?(index: number, address: Address): Promise<void>`

Update an address for a customer.

`applyCartDiscount?(type: DiscountType, discountDescription: string, amount: string): Promise<void>`

Apply a percentage or fixed amount discount to the whole cart.

`applyCartCodeDiscount?(code: string): Promise<void>`

Apply a code discount to the whole cart.

`removeCartDiscount?(): Promise<void>`

Remove the discount applied to the whole cart.

`removeAllDiscounts?(disableAutomaticDiscounts: boolean): Promise<void>`

Clears all applied discounts from the cart and optionally disables automatic discounts.

`addCartProperties?(properties: Record<string, string>): Promise<void>`

Add properties for the cart.

`removeCartProperties?(keys: string[]): Promise<void>`

Remove properties from the cart.

`addCustomSale?(customSale: CustomSale): Promise<void>`

Add custom sale for the cart.

`clear?(): Promise<void>`

Clear all contents from the cart.

`addLineItem?(variantId: number, quantity: number): Promise<void>`

Add a product to the cart.

`updateLineItem?(uuid: string, quantity: number): Promise<void>`

Make changes to a line item in the cart.

`removeLineItem?(uuid: string): Promise<void>`

Remove a line item in the cart.

`setLineItemDiscount?(uuid: string, type: DiscountType, discountDescription: string, amount: string): Promise<void>`

Apply a discount to a line item.

`removeLineItemDiscount?(uuid: string): Promise<void>`

Remove a discount from a line item.

`addLineItemProperties?(uuid: string, properties: Record<string, string>): Promise<void>`

Add properties to a line item.

`removeLineItemProperties?(uuid: string, properties: string[]): Promise<void>`

Remove properties from a line item.

Used in: [`PosCart`](#poscart)

### `Device` {#device}

`name: string`

The name of the device.

`serialNumber: string`

The unique ID associated device ID and app ID..

Used in: [`PosDevice`](#posdevice)

### `Location` {#location}

`id: number`

The ID of current location.

`active: boolean`

The status of current location.

`name: string`

The name of current location.

`locationType?: string`

The type of current location.

`address1?: string`

The primary address of current location.

`address2?: string`

Any extra information associated with the address (Apartment #, Suite #, Unit #, etc.).

`zip?: string`

The ZIP or postal code of the address.

`city?: string`

The name of the city.

`province?: string`

TThe province or state of the address.

`countryCode?: string`

The Country Code in ISO 3166-1 (alpha-2) format.

`countryName?: string`

The country of the address.

`phone?: string`

The phone number of the location.

Used in: [`PosLocation`](#poslocation)

### `Address` {#address}

`address1?: string`

The customer's primary address.

`address2?: string`

Any extra information associated with the address (Apartment #, Suite #, Unit #, etc.).

`city?: string`

The name of the customer's city.

`company?: string`

The company name associated with address.

`firstName?: string`

The first name of the customer.

`lastName?: string`

The last name of the customer.

`phone?: string`

The phone number of the customer.

`province?: string`

The province or state of the address.

`country?: string`

The country of the address.

`zip?: string`

The ZIP or postal code of the address.

`name?: string`

The name of the address.

`provinceCode?: string`

The acronym of the province or state.

`countryCode?: string`

The Country Code in ISO 3166-1 (alpha-2) format.

Used in: [`_PosCart`](#_poscart)

### `Cart` {#cart}

`subTotal: string`

The total cost of the current cart including discounts, but before taxes and shipping. Value is based on the shop's existing currency settings.

`taxTotal: string`

The sum of taxes for the current cart. Value is based on the shop's existing currency settings.

`grandTotal: string`

The total cost of the current cart, after taxes and discounts have been applied. Value is based on the shop's existing currency settings.

`cartDiscount?: Discount`

The current discount applied to the entire cart.

`cartDiscounts?: Discount[]`

All current discounts applied to the entire cart and line items.

`customer?: Customer`

The customer associated to the current cart.

`lineItems: LineItem[]`

A list of lineItem objects.

`properties: Record<string, string>`

A list of objects containing cart properties.

Used in: [`CartSubscriber`](#cartsubscriber), [`_PosCart`](#_poscart)

### `CartSubscriber` {#cartsubscriber}

```ts
type CartSubscriber = (cart: Cart) => void;
```

References: [`Cart`](#cart)
Used in: [`_PosCart`](#_poscart)

### `Customer` {#customer}

`id: number`

The ID of existing customer.

`email?: string`

The email for a new customer.

`firstName?: string`

The first name for new customer.

`lastName?: string`

The last name for new customer.

`note?: string`

The note for new customer.

Used in: [`Cart`](#cart), [`_PosCart`](#_poscart)

### `CustomSale` {#customsale}

`price: number`

Price of line item

`quantity: number`

Quantity of line item.

`title: string`

Title of line item.

`taxable: boolean`

If line item charges tax.

Used in: [`_PosCart`](#_poscart)

### `DiscountType` {#discounttype}

```ts
type DiscountType = "Percentage" | "FixedAmount";
```

Used in: [`Discount`](#discount), [`_PosCart`](#_poscart)

### `Unsubscribe` {#unsubscribe}

```ts
type Unsubscribe = () => void;
```

Used in: [`_PosCart`](#_poscart)

### `Discount` {#discount}

`amount: number`

Amount of discount. Only for fixed or percentage discounts.

`discountDescription?: string`

Description of discount.

`type: DiscountType`

Type of discount.

Used in: [`Cart`](#cart), [`LineItem`](#lineitem)

### `LineItem` {#lineitem}

`uuid: string`

Unique id of line item

`price?: number`

Price of line item

`quantity: number`

Quantity of line item.

`title?: string`

Title of line item.

`variantId?: number`

Variant identifier for line item.

`productId?: number`

Product identifier for line item.

`discounts: Discount[]`

Discount applied to line item.

`taxable: boolean`

If line item charges tax.

`sku?: string`

Stock keeping unit of the line item.

`vendor?: string`

Vendor of line item.

`properties: { [key: string]: string; }`

Properties of the line item.

`isGiftCard: boolean`

If the line item is a gift card.

Used in: [`Cart`](#cart)

## `ScannerApi` {#scannerapi}

`capture(): Promise<ScannerPayload>`

Opens the device camera to scan a barcode. Returns a Promise that resolves to a `ScannerPayload` containing the scanned data. A new call to `capture` rejects a pending call with an `AbortError`.

Used in: [useAppBridge()](/app-bridge/use-app-bridge), [`ShopifyGlobal`](/app-bridge/types/#shopifyglobal)

### `ScannerPayload` {#scannerpayload}

`data: string`

The scanned barcode data as a string.

Used in: [useAppBridge()](/app-bridge/use-app-bridge), [`ScannerApi`](#scannerapi)

## `WebVitalsApi` {#webvitalsapi}

`onReport?: (callback: WebVitalsCallback | null) => Promise<void>`

Registers a callback to receive Web Vitals performance data. Pass `null` to unregister a previously registered callback.

Used in: [useAppBridge()](/app-bridge/use-app-bridge), [`ShopifyGlobal`](/app-bridge/types/#shopifyglobal)

### `WebVitalsCallback` {#webvitalscallback}

```ts
type WebVitalsCallback = (payload: WebVitalsReport) => void | Promise<void>;
```

References: [`WebVitalsReport`](#webvitalsreport)
Used in: [`WebVitalsApi`](#webvitalsapi)

### `WebVitalsReport` {#webvitalsreport}

`metrics: WebVitalsMetric[]`

The array of Web Vitals metric measurements included in this report.

Used in: [`WebVitalsCallback`](#webvitalscallback)

### `WebVitalsMetric` {#webvitalsmetric}

`id: string`

A unique identifier for this metric measurement instance.

`name: string`

The name of the metric, such as `LCP`, `FCP`, `CLS`, `INP`, or `TTFB`.

`value: number`

The measured value of the metric. Units depend on the metric name (milliseconds for timing metrics, unitless for CLS).

`country?: string`

The country code where the metric was collected, if available.

`version?: string`

The App Bridge build version that produced the metric, in the form `<package-version>` or `<package-version>+<short-commit-sha>`. Used to attribute reports to a specific deploy.

Used in: [`WebVitalsReport`](#webvitalsreport)
