Skip to content

Global Configuration

The app.json file in the root directory of the mini program is used to configure the mini program globally. The content of the file is a JSON object.

Configuration Items

PropertyTypeRequiredDescription
entryPagePathstringNoThe default launch page of the mini program
pagesstring[]YesList of page paths
windowObjectNoGlobal default window presentation
tabBarObjectNoBottom tab bar presentation
networkTimeoutObjectNoNetwork timeout settings
debugbooleanNoWhether to enable debug mode, default is false
subpackagesObject[]NoSubpackage structure configuration
preloadRuleObjectNoSubpackage pre-download rules
workersstringNoDirectory for Worker code
requiredBackgroundModesstring[]NoCapabilities required in the background, e.g., "audio"
pluginsObjectNoPlugins used
resizablebooleanNoWhether PC mini program supports arbitrary window resizing
usingComponentsObjectNoGlobal custom component configuration
permissionObjectNoMini program interface permission settings
sitemapLocationstringYesLocation of sitemap.json
stylestringNoSpecify to use upgraded weui style
useExtendedLibObjectNoSpecify extended libraries to reference
entranceDeclareObjectNoWeChat message open with mini program
darkmodebooleanNoWhether mini program supports DarkMode
themeLocationstringNoLocation of theme.json
lazyCodeLoadingstringNoConfigure custom component code on-demand injection
singlePageObjectNoSingle page mode configuration

entryPagePath

Specifies the default launch path (homepage) of the mini program. Common scenarios include launching from the chat list dropdown or the mini program list. If not filled, it defaults to the first item in the pages list. Page path parameters are not supported.

pages

Used to specify which pages the mini program consists of. Each item corresponds to the path (including filename) of a page. The filename does not need a suffix; the framework will automatically look for the corresponding .json, .js, .wxml, and .wxss files.

When entryPagePath is not specified, the first item in the array represents the initial page (homepage) of the mini program.

Example:

json
{
  "pages": [
    "pages/index/index",
    "pages/logs/logs"
  ]
}

window

Used to set the status bar, navigation bar, title, and window background color of the mini program.

PropertyTypeDefaultDescription
navigationBarBackgroundColorHexColor#000000Navigation bar background color
navigationBarTextStylestringwhiteNavigation bar title and status bar color, supports black / white
navigationBarTitleTextstringNavigation bar title text
navigationStylestringdefaultNavigation bar style, supports default / custom
backgroundColorHexColor#ffffffWindow background color
backgroundTextStylestringdarkPull-down loading style, supports dark / light
backgroundColorTopstring#ffffffTop window background color (iOS only)
backgroundColorBottomstring#ffffffBottom window background color (iOS only)
enablePullDownRefreshbooleanfalseWhether to enable global pull-down refresh
onReachBottomDistancenumber50Distance from bottom when reach bottom event triggers, in px
pageOrientationstringportraitScreen orientation, supports auto / portrait / landscape

tabBar

If the mini program is a multi-tab application (tabs at the bottom or top of the client window), you can use the tabBar configuration item to specify the presentation of the tab bar and the paths of the pages corresponding to the tabs.

PropertyTypeRequiredDefaultDescription
colorHexColorYesText color on tab
selectedColorHexColorYesText color when tab is selected
backgroundColorHexColorYesBackground color of tab
borderStylestringNoblackBorder color of tabbar, supports black / white
listArrayYesList of tabs, see list property description, min 2, max 5 tabs
positionstringNobottomPosition of tabBar, supports bottom / top
custombooleanNofalseCustom tabBar

list

PropertyTypeRequiredDescription
pagePathstringYesPage path, must be defined in pages
textstringYesButton text on tab
iconPathstringNoImage path, icon size limit 40kb, suggested size 81px * 81px
selectedIconPathstringNoImage path when selected

networkTimeout

Timeout for various network requests, in milliseconds.

PropertyTypeDefaultDescription
requestnumber60000wx.request timeout
connectSocketnumber60000wx.connectSocket timeout
uploadFilenumber60000wx.uploadFile timeout
downloadFilenumber60000wx.downloadFile timeout

debug

You can enable debug mode in the developer tools. In the console panel of the developer tools, debug information is given in the form of info, including Page registration, page routing, data updates, event triggering, etc. This helps developers quickly locate common problems.

usingComponents

Custom components declared here are treated as global custom components and can be used directly in pages or custom components within the mini program without further declaration.

json
{
  "usingComponents": {
    "my-component": "/components/my-component/my-component"
  }
}

Released under the Apache-2.0 License.