---
name: "navigateToMiniProgram"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.2.4" }
platform:
  - "iOS"
  - "Android"
async: true
---

## navigateToMiniProgram

> [VERSION] BaseKit >= 2.2.4

> [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 miniapp agent to open. preview: trial version release: release version |
| `path` | `string` | No | - | `2.2.4` | The page path to open; if empty, opens the home page. The part after ? in path becomes the query, available in the miniapp's `App.onLaunch`, `App.onShow`, and `Page.onLoad` callbacks. |
| `position` | `string` | No | `"right"` | `2.5.1` | Transition mode for opening the miniapp, right\|bottom indicating horizontal and vertical directions. |
| `extraData` | `Record<string, any>` | No | - | `2.2.4` | Data passed to the target miniapp; the target can retrieve it in `App.onLaunch` and `App.onShow`. |
| `envVersion` | `string` | No | `"release"` | `2.2.4` | Version of the miniapp to open. This parameter takes effect only when the current miniapp is a development or trial build. If the current miniapp is release, the opened miniapp will 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 | - | - | Callback on API call completion (invoked on success and failure) |
| `success` | `() => void` | No | - | - | Callback when the API call succeeds |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Callback when the API call fails |

#### 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` | Extended error code |
| `errorMsg` | `string` | Extended error info |


### Examples

```tsx
ty.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);
  },
});
```
