Backend Development 8 min read

Eliminating Backend Dependency in Mini‑Games with Cloud Development

By replacing a traditional server with just two Tencent Cloud functions that handle WeChat API calls, token refresh, data storage, and leaderboard queries, the mini‑game “LeXiang Garden” was built in three days, eliminating backend dependency and dramatically lowering development complexity for mini‑games.

Tencent Cloud Developer
Tencent Cloud Developer
Tencent Cloud Developer
Eliminating Backend Dependency in Mini‑Games with Cloud Development

Daichang Xin, a game client developer at Shanghai Xiangwu Talk, shares the development experience of the mini‑game "LeXiang Garden". The entire client was completed in just three days, but the game relied on browser cache for tasks such as planting and watering, which would be lost if the user cleared the phone cache. A proper backend was required to persist data, leading to a delay of several weeks until server resources were available.

Problem: Mini‑Game Development Pain – Inability to Escape Server Dependency

Two main dependencies on the backend are identified:

1. WeChat APIs can only be called from the server. Without a middle‑tier server, user login, avatar retrieval, access_token acquisition, and content moderation cannot be performed.

2. Game features that need server logic. Most mini‑games only require a server to store level progress or display a global leaderboard, but implementing these features with a traditional server involves a steep learning curve.

Solution: Cloud Development (Tencent Cloud) to Remove Server Pain Points

Using cloud functions, the author bypasses the need for a dedicated server:

• Cloud functions can call WeChat APIs directly, handling login (openid) and retrieving unionid for cross‑platform integration.

• Access tokens, which expire after two hours, are refreshed automatically via timed triggers and stored in the cloud database, ensuring they never become stale.

• The cloud database replaces a traditional server for persisting user data and generating a global leaderboard.

Two cloud functions were sufficient for the entire game:

1. Leaderboard Function – Retrieves up to 100 entries from the cloud database (the limit is sufficient for most scenarios). Adding indexes to the database improves query performance.

2. Player Data Reporting Function – A single line of code uploads player data to the database.

By leveraging cloud development, the need for a separate server to act as a WeChat API proxy disappears, and the backend becomes independent of the client platform (H5, mini‑program, etc.).

Conclusion

Cloud development can address many scenarios beyond the ones demonstrated, such as bypassing HTTPS domain restrictions, storing global game settings, saving personalized player data, and supporting future features like WebSocket chat, frame‑synchronised real‑time battles, logging services, and big‑data analytics. This dramatically lowers the entry barrier for mini‑game development.

backendGame developmentcloud functionsmini-gamecloud development
Tencent Cloud Developer
Written by

Tencent Cloud Developer

Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.