---
name: "navigateToMiniProgram"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.2.4" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## navigateToMiniProgram

> [VERSION] BaseKit >= 2.2.4 | @ray-js/ray >= 0.3.23

> [PLATFORM] iOS, Android

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

### Description

Open another miniapp

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `appId` | `string` | No | - | `2.2.4` | appId of the miniapp to open |
| `aiPtChannel` | `string` | No | - | `3.13.0` | Agent ID of the agent miniapp to open |
| `aiPtType` | `string` | No | `"release"` | `3.13.0` | Version of the agent miniapp to open. preview: preview version release: release version |
| `path` | `string` | No | - | `2.2.4` | Page path to open; if empty, the home page opens. The part after ? in path becomes the query and is available in the callbacks of `App.onLaunch`, `App.onShow`, and `Page.onLoad` |
| `position` | `string` | No | `"right"` | `2.5.1` | Transition type when opening the miniapp: right \| bottom, indicating horizontal and vertical directions |
| `extraData` | `Record<string, any>` | No | - | `2.2.4` | Data to pass to the target miniapp; the target can access it in `App.onLaunch` and `App.onShow` |
| `envVersion` | `string` | No | `"release"` | `2.2.4` | Version of the miniapp to open. This parameter is valid only when the current miniapp is a dev or trial build. If the current miniapp is release, the opened miniapp must be release. trial: trial version release: release version |
| `shortLink` | `string` | No | - | `2.2.4` | Miniapp link. When this parameter is provided, appId and path can be omitted |
| `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 |


### Examples

#### Demo

```tsx
import { navigateToMiniProgram } from '@ray-js/ray'

navigateToMiniProgram({
  appId: "tyeavwo0j4oocvdrf1",
  path: "pages/myService/index?categoryCode=ai_inspection_service",
  position: "right",
  envVersion: "release",
  extraData: { source: "ttt-demo", debug: true },
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});
```
