MiniGame (Cocos) Quick Start
- AI Quick Start
- Full Developer Guide
Prerequisites
Before you begin, ensure you have completed the following:
- Activate CloudBase Environment: Create Environment
- Development Tools: Download and install WeChat DevTools
- Mini Program Account: Register WeChat Mini Program to get your AppID
Client
Configure your AI tool to connect with CloudBase capabilities. Supports local and hosted connection. See connection modes.
Step 1: Install / Configure CloudBase
Step 2: Chat with AI
Enter the following in your AI chat in order:
prompt
Install CloudBase Skills: run npx skills add tencentcloudbase/cloudbase-skills -yUse CloudBase Skills: Use CloudBase Skills: Integrate cloud development in MiniGame (Cocos), including database and cloud storagePrerequisites
Before you begin, ensure you have completed the following:
- Activate CloudBase Environment: Create Environment
- Development Tools: Download and install WeChat DevTools
- Mini Program Account: Register WeChat Mini Program to get your AppID
For more details, see: MiniGame (Cocos) Full Documentation
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;