---
name: "openMiniWidget"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "3.0.3" }
  - { name: "@ray-js/ray", version: "0.8.0" }
platform:
  - "iOS"
  - "Android"
async: true
title: "MiniWidgetDialog openMiniWidget"
---

## openMiniWidget

> [VERSION] BaseKit >= 3.0.3 | @ray-js/ray >= 0.8.0

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Open the widget popup

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `appId` | `string` | Yes | - | `3.0.3` | AppID of the widget to open |
| `pagePath` | `string` | No | - | `3.0.3` | Relative URL of the widget page; if empty, opens the home page. The part after ? in path becomes the query |
| `deviceId` | `string` | No | - | `3.0.3` | Panel-type device ID |
| `groupId` | `string` | No | - | `3.0.3` | Panel-group type group ID |
| `style` | `string` | No | `"middle"` | `3.0.3` | Widget style, default: middle |
| `versionType` | `"release" \| "preview"` | No | `'release'` | `3.0.3` | Version type, default: release |
| `version` | `string` | No | - | `3.0.3` | Version |
| `position` | `"bottom" \| "top" \| "center"` | No | `'bottom'` | `3.0.3` | Display position, default: bottom |
| `autoDismiss` | `boolean` | No | `true` | `3.0.4` | Whether clicking outside closes the popup |
| `autoCache` | `boolean` | No | `true` | `3.1.0` | Whether to prioritize showing the default cache. This property takes effect in Miniapp container 3.1.0 |
| `supportDark` | `boolean` | No | `true` | `3.1.3` | Whether dark mode is supported |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `() => void` | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Valid Values

##### `versionType` valid values

| Value | Description |
| --- | --- |
| `"release"` | Production version |
| `"preview"` | Pre-release version |

##### `position` valid values

| Value | Description |
| --- | --- |
| `"bottom"` | Display at the bottom |
| `"top"` | Display at the top |
| `"center"` | Display in the center |


### Examples

#### Demo

```tsx
import { home, openMiniWidget } from '@ray-js/ray'

// deviceId is an optional parameter for panel widgets; use the first device under the current account.
const { homeId } = await home.getCurrentHomeInfo();
const { devIds } = await home.getDeviceIdList({ ownerId: homeId, roomId: 80079606, devId: "vdevo178158139173829" });

const dialog = await openMiniWidget({
  appId: "ty8gpajcefnj0capj4",
  deviceId: devIds[0],
  pagePath: "/cards/alarm/index",
  position: "bottom",
  style: "1.3",
  versionType: "release",
  autoCache: false,
  autoDismiss: true,
  supportDark: true,
});

console.log(dialog);
```
