---
title: app.js MiniApp Registration
---

# app.js MiniApp Registration

## App(config: Object) registration function

Register a miniapp. An Object parameter is used to specify the miniapp's lifecycle callback.

`App()` must be called in the app.js file only once. Otherwise, unexpected consequences might occur.

For more information about `App()`, see [App](/en/miniapp/develop/miniapp/framework/api/app).

## App instance

After the miniapp is registered, there will be a unique instance object in the context. You can get the instance object by using [getApp()](/en/miniapp/develop/miniapp/framework/api/getApp). With the global instance, common methods of the page or shared data can be saved for future page requests.

Example:

```js
// app.js
App({
  say: function () {
    console.log('hello world');
  },
  globalData: {
    key: 'value',
  },
});
```

```js
// pages/home/index.js
const app = getApp();
Page({
  onLoad: function () {
    var v = app.globalData.key; // Shared data
    app.say(); // Call the specified function
  },
});
```
