An Introduction to WeChat Mini Programs: Technology Stack, Development Settings, and Lifecycle
This article provides a comprehensive overview of WeChat Mini Programs, covering their technical stack (WXML, WXSS, WXAPI), development environment setup, file architecture, component system, application and page lifecycles, login process, and practical considerations for frontend developers.
WeChat Mini Programs have become a hot front‑end topic in 2017 due to their ability to run without installation, fast distribution, and excellent user experience, fulfilling Tencent’s goal of making applications instantly accessible.
Technically, a Mini Program is a web‑based offline package built on the WeChat platform, offering a rich set of animations and APIs. Developers use WXML for markup, WXSS for styling, and WXAPI for native capabilities such as user info, storage, and payment.
The framework supplies a collection of basic components (e.g., <view> , <scroll-view> , <swiper> , <picker> ) that encapsulate common UI patterns, allowing rapid development without external plugins.
In JavaScript, the usual browser objects (window, document) are unavailable; instead, a global wx object provides network, media, storage, location, UI interaction, login, payment, and other services. Local storage is accessed via wx.setStorage / wx.getStorage with a 10 MB limit.
To start development, developers must obtain an admin account, add a whitelist, retrieve the AppID/AppSecret, configure server domains, and use the WeChat Mini Program IDE, which enforces HTTPS requests and QR‑code verification.
The recommended project structure includes app.js (logic), app.json (global configuration), and app.wxss (global styles). Pages are organized under a pages directory, with additional folders such as components , assets , business , utils , adapter , service , and mock for modular development.
The Mini Program runtime separates logic and view layers: the logic layer processes data and communicates with the view layer, similar to MVVM but disallowing direct DOM manipulation.
Application lifecycle consists of onLaunch → onShow → onHide , with onError triggered on script errors. The program is not destroyed immediately when the user leaves; it is terminated only after being in the background for a certain period or when system resources are low.
Page lifecycle follows onLoad → onShow → onReady → onHide → onUnload , allowing developers to manage data loading, rendering, and cleanup at appropriate stages.
Login is handled via wx.login , which returns a temporary code. The backend exchanges this code for an openid and session_key , then issues its own session token (e.g., 3rd_session ) that the Mini Program stores locally for subsequent authenticated requests.
In summary, Mini Programs are easy to adopt for developers with front‑end experience, offering a low entry barrier and high development efficiency thanks to Tencent’s extensive component and API encapsulation. The platform builds on concepts previously explored by services like Baidu Nuomi, providing a solid foundation for rapid iteration and robust monitoring.
Baidu Waimai Technology Team
The Baidu Waimai Technology Team supports and drives the company's business growth. This account provides a platform for engineers to communicate, share, and learn. Follow us for team updates, top technical articles, and internal/external open courses.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.