# Register Mini Program

Each Mini Program needs to be in the app.js Call in App Method to register Mini Program instance, binding life cycle callback function, error listening and page does not exist listening function.

Please refer to the detailed meaning and use of parameters App Reference documents

// app.js
App({
  onLaunch (options) {
    // Do something initial when launch.
  },
  onShow (options) {
    // Do something when show.
  },
  onHide () {
    // Do something when hide.
  },
  onError (msg) {
    console.log(msg)
  },
  globalData: 'I am global data'
})

There is only one Mini Program. App Examples are shared across all pages. Developers can use getApp Method gets the globally unique App Instance, get data on the app or call the developer registered in the App Function on.

// xxx.js 
const appInstance = getApp()
console.log(appInstance.globalData) // I am global Data