Skip to main content

Hello World

Leverage CloudBase to rapidly build websites and mini programs, effortlessly achieve multi-end synchronization, and help developers easily embark on their cloud development journey.

Extended Work Mode

When you use this extension:

  1. Cloud functions render web pages.
  2. web pages and mini programs monitor changes in page content input and synchronize.

Prerequisites

CloudBase has been provisioned.

Install Extension

! WeChat Mini Program developers should use [Other login methods] - [Official Account Login] to log in, then select the associated mini program account. QQ Mini Program developers can log in directly via the [CloudBase] button in the QQ Mini Program IDE, or through an associated Tencent Cloud account.

You can install and manage extensions via the CloudBase Console.

Use Extension

  1. Go to the CloudBase Console, click on the environment where you want to install the extension (hereinafter referred to as custom_env for the environment ID), then click [Environment Settings] in the left sidebar to access the environment settings page:
  • 1.1 Click [Login Methods], turn on the [Anonymous Login] switch to allow the application to access CloudBase using anonymous login.

  • 1.2 Click [Security Configuration], then click [Add Domain] under web Security Domains to add the default domain for HTTP-triggered Cloud Functions in the current environment: \${custom_env}.service.tcloudbase.com (this domain is allocated by CloudBase for HTTP-triggered functions. For details, refer to HTTP Triggering), allowing CloudBase invocation on pages under this domain.

  • 1.3 Go to [Security Configuration], then register touristappid in [Mobile Application Security Sources]. After successful addition, obtain the credential information for later use;

    1. Go to [Cloud Database] in the custom_env environment, locate the tcb_hello_world collection and access its details. Navigate to the [Permission Settings] tab, click [Switch to Security Rules], and enter:
{
"read": true,
"write": true
}
  1. web: Access https://${custom_env}.service.tcloudbase.com/tcb_hello_world via browser; 4. WeChat Mini Program: Visit Hello World to get the code snippet, import it into WeChat Developer IDE with one click (do not configure AppID); Update the following configuration in the project's app.js:
const cloud = tcb.init({
env: "${custom_env}", // current environment's ID
appSign: "touristappid",
appSecret: {
appAccessKeyId: "Mobile Application Security Sources version", // Mobile application security source version obtained in Step 1.3
appAccessKey: "Mobile Application Security Sources Credential" // Mobile application security source credential obtained in Step 1.3
}
});
  1. Drag the number in the web or Mini Program, and the same change will be seen on the other end.

! This extension is a sample Demo. Please follow the usage instructions to complete the configuration. When registering security sources, use touristappid; when experiencing in the Mini Program, there is no need to configure AppID, just fill in the version and credential information corresponding to touristappid.

Other

Extension Configuration Information

You can configure the following parameters:

  • Environment ID: Select the environment to deploy to, specifying where it will be used.

Billing

This extension uses other CloudBase or other Tencent Cloud services, which may incur relevant fees:

When using CloudBase extensions, you only pay for the cloud resources you consume; CloudBase is billed separately from other cloud resources. You can view detailed information in the Billing Center.

Created Resources

  • Type: Cloud Function Description: Leverage CloudBase http service capabilities to render web pages, enabling developers to experience CloudBase features.
  • Type: Cloud DB Description: Store user operation data, leverage real-time database capabilities to monitor data changes, and achieve multi-end data synchronization.

Permission Granting

Primary Account

This extension capability can be accomplished using CloudBase's own resources, and no additional permissions need to be granted.

Sub-account

If you want a sub-account to be able to use this extension, you need to grant the following permissions to the sub-account:

  • Policy: QcloudAccessForTCBRole Description: Access permissions for CloudBase (TCB) to cloud resources.