---
name: "onAppShow"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.10.0" }
title: "ty.onAppShow - Listen for the event in which a miniapp switches to the foreground, callback parameters are consistent with App.onShow"
---

## onAppShow

> [VERSION] Base Library >= 2.10.0

### Description

Listen for the Mini Program switching to foreground event. This event has the same callback parameters as App.onShow.

### Parameters

`(callback: Function)`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `callback` | `(res: OnAppShowCallbackResult) => void` | Yes | Callback for the Mini Program entering the foreground |

### Return Value

None


### Referenced Types

##### `interface` OnAppShowCallbackResult

| Property | Type | Description |
| --- | --- | --- |
| `path` | `string` | Path used to launch the Mini Program |
| `query` | `Record<string, string>` | Query parameters used to launch the Mini Program |
| `scene` | `number` | Launch scene value |
| `referrerInfo` | `ReferrerInfo` | Referrer info |

##### `interface` ReferrerInfo

| Property | Type | Description |
| --- | --- | --- |
| `appId` | `string` | appId of the referring Mini Program or Official Account |
| `extraData` | `Record<string, unknown>` | Data passed from the referring Mini Program |


### Examples

#### Listen for the mini program entering the foreground

```js
// app.js
App({
  onShow(res) {
    console.log('Mini Program moved to foreground', res.path, res.query);
  },
});

// Or use in a page
// page.js
Page({
  onLoad() {
    ty.onAppShow((res) => {
      console.log('Mini Program moved to foreground', res.path, res.query);
    });
  },
});
```
