All Products
Document Center

Specify the page to redirect to when starting the Mini Program

Last Updated: Jun 04, 2021

In certain scenarios, you need to specify the page to redirect to when starting the Mini Program. This topic describes how to implement this operation.


You have accessed the mini program component by referring to Quick start.


  1. Add parameter information of page redirection during startup on the client. The parameter passing method is as follows:
    1. Bundle param = new Bundle();
    2. String query = "name=123&pwd=456";
    3. param.putString("query",query); // Set the parameter.
    4. param.putString("page","pages/twoPage/twoPage"); // Set the path.
    5. MPNebula.startApp(appId:"2020121620201216",param);
    • Description of Bundle parameters:
      • query: The parameter that is passed during Mini Program redirection, which is linked with key=value. Separate parameters with ampersand (&).
      • page: The redirection path of the Mini Program, which defaults to pages/index/index when not specified.
    • Description of startApp parameters:
      • appId: The app ID of the mini program, which can be viewed in the mPaaS console.
      • param: The Bundle object. You can pass request parameters to the Bundle object in the format of key="query",value="Key-value pair". Separate parameters with ampersand (&).
  2. Obtain the passed parameters in the Mini Program. To do this, the Mini Program obtains the parameters from the options parameter of the onLaunch/onShow(options) method.
    The app.js storage script obtains the parameters passed from the client to the Mini Program and stores them to the globalData global variable. To use these parameters, the Mini Program directly obtains or updates the globalData value. After parameters such as token and user_id in the request header are passed from Native and stored in globalData, the Mini Program directly obtains the globalData value and use the parameters.