title: Taro.navigateToMiniProgram(option)

sidebar_label: navigateToMiniProgram

Opens another Mini Program.

Use Limits

Redirection needs to be triggered by user

As of the base library 2.3.0, if a user does not tap any location on the Mini Program page, this API cannot be called to automatically redirect to another Mini Program.

User confirmation is required before redirection

As of the base library 2.3.0, before redirection to another Mini Program, a pop-up window needs to be added to ask whether redirection is allowed. If yes, the user can be redirected to another Mini Program after confirmation. If the user taps Cancel, fail cancel is called back.

Each Mini Program can be redirected to a maximum of 10 Mini Programs.

As of the base library 2.4.0 and the specific date (to be determined), if the feature of redirection to another Mini Program is used in a new version of Mini Program code, the developer needs to declare a list of to-be-redirected-to Mini Programs in the code configurations. The quantity of to-be-redirected-to Mini Programs must be not more than 10. Otherwise, the Mini Program code will fail to pass the review. The list can be updated when a new version is released, and cannot be dynamically modified. For a specific configuration method, see Global Configuration of Mini Program. Before calling this API, ensure that the appId of the Mini Program to be redirected to is in the configuration list. Otherwise, the following result is returned after callback: fail appId "${appId}" is not in navigateToMiniProgramAppIdList.

About Debugging

  • When this API is called via WeChat DevTools, the user is not actually redirected to another Mini Program. However, WeChat DevTools will check whether this call for redirection is successful. Details
  • On WeChat DevTools, the processing of received parameters by the redirected Mini Program can be debugged. Details

Reference

Type

  1. (option: Option) => Promise<CallbackResult>

Parameters

Option

Property Type Required Description
appId string Yes The appId of the Mini Program to be opened
envVersion "develop" | "trial" | "release" No The version of the Mini Program to be opened. This parameter is valid only when the current Mini Program is in the developer version or the test version. If the current Mini Program is in the official version, the opened Mini Program is definitely in the official version.
extraData Record<string, any> No The data that needs to be passed to the target Mini Program. The target Mini Program can obtain this data from App.onLaunch and App.onShow. If the user is redirected to a Mini Game, this data can be obtained from wx.onShow and wx.getLaunchOptionsSync.
path string No The path of the page to be opened. If it is empty, the homepage is opened. Content following the question mark (?) in the path becomes a query. The query data can be obtained from the callbacks for App.onLaunch, App.onShow, and Page.onLoad of the Mini Program, the callback for wx.onShow of the Mini Game, and wx.getLaunchOptionsSync. For Mini Games, you can pass in only the query part, for example, ?foo=bar.
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

envVersion

Property Description
develop Developer version
trial Test version
release Official version

Sample Code

  1. Taro.navigateToMiniProgram({
  2. appId: '',
  3. path: 'page/index/index?id=123',
  4. extraData: {
  5. foo: 'bar'
  6. },
  7. envVersion: 'develop',
  8. success: function(res) {
  9. // Opened successfully
  10. }
  11. })

API Support

API WeChat Mini-Program H5 React Native
Taro.navigateToMiniProgram ✔️