# wx.navigateToMiniProgram(Object object)

Start from base library version 2.2.0. Please remaining backward compatible.

Opens another Mini Program.

# Parameters

# Object object

Attribute Type Default Required Description
appId string Yes The appId of the Mini Program to be opened
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.
extraData object 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.
envVersion string 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.
success function No The callback function for a successful API call
fail function No The callback function for a failed API call
complete function No Callback function used when API call completed (always executed whether call succeeds or fails)

Valid values of object.envVersion

Value Description Minimum Version
develop Developer version
trial Test version
release Official

# 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

# Sample Code

wx.navigateToMiniProgram({
  appId: '',
  path: 'page/index/index?id=123',
  extraData: {
    foo: 'bar'
  },
  envVersion: 'develop',
  success(res) {
    // Opened successfully
  }
})
点击咨询小助手