Skip to main content

MiniGame (Cocos) Quick Start

Prerequisites​

Before you begin, ensure you have completed the following:

  1. Activate CloudBase Environment: Create Environment
  2. Development Tools: Download and install WeChat DevTools
  3. Mini Program Account: Register WeChat Mini Program to get your AppID

⚠️ When signing in to the CloudBase console, choose "WeChat Official Accounts Platform account" (for mini programs, mini games, and Official Account web pages), not a Tencent Cloud account — the wrong choice leaves your environment unbound to your mini program, and every step after that fails.

For more details, see: MiniGame (Cocos) Full Documentation

Install the CloudBase AI Plugin​

Optional: If you develop with an AI coding assistant (such as Cursor, Claude Code, CodeBuddy, etc.), we recommend completing this step so the AI has CloudBase development capabilities.

Copy the AI prompt into your AI IDE​

Enter the following in your AI chat:

Read https://docs.cloudbase.net/skill.md and set up CloudBase for me.
Tell me when you're done, and suggest the most relevant next steps.

View skill.md →

Develop with Skills​

Tell the AI:

Use CloudBase Skills: Integrate CloudBase in MiniGame (Cocos), including database and cloud storage

Skills docs →

You can also install CloudBase Skills manually:

npx skills add tencentcloudbase/cloudbase-skills -y

Want the AI to think in mini-program terms? The WorkBuddy Expert Center has a CloudBase mini-program expert — requirement breakdown, page structure, and which cloud API to use, all the mini-program way. Open the expert →

Install SDK​

@cloudbase/js-sdk Combine with @cloudbase/adapter-cocos_native allows you toin Cocos projectaccess CloudBase services and resources。

npm​

npm i @cloudbase/js-sdk @cloudbase/adapter-cocos_native

yarn​

yarn add @cloudbase/js-sdk @cloudbase/adapter-cocos_native

pnpm​

pnpm add @cloudbase/js-sdk @cloudbase/adapter-cocos_native

Initialize SDK​

Add the following code to your Cocos project

scripts/services/CloudbaseService.js​

import cloudbaseSDK from "@cloudbase/js-sdk";
import adapter from "@cloudbase/adapter-cocos_native";

// Registeradapter
cloudbaseSDK.useAdapters(adapter);

const cloudbase = cloudbaseSDK.init({
// Environment ID
env: "{%ENV_ID%}",
// region
region: "{%REGION%}",
// Anonymous access token
accessKey: "{%PUBLISHABLE_KEY%}"
});

export default cloudbase;