Cloud Development (Tencent CloudBase, TCB) is a cloud-native integrated development environment and tool platform provided by Tencent Cloud. It provides developers with highly available, automatically and elastically scalable back-end cloud services, including serverless capabilities such as computing, storage, and hosting. , Can be used for cloud integration to develop a variety of end applications (small programs, official accounts, web applications, Flutter clients, etc.) to help developers build and manage back-end services and cloud resources in a unified manner, avoiding cumbersome servers in the application development process With construction and operation and maintenance, developers can focus on the realization of business logic, with lower development thresholds and higher efficiency.

Why use cloud development?

From a personal point of view, cloud development brings several benefits to developers:

  • Simple login logic and automatic verification of user login, no need to re-authenticate
  • With free tier, more than enough for individual developers
  • Simple: The call is very simple, you only need to understand JavaScript and some simple asynchronous knowledge (promise).
  • Free operation and maintenance: You don't need to pay attention to server throughput and other operation and maintenance knowledge, cloud development can easily handle it for you!
  • Advantages: cloud-native integrated services, high efficiency, speed, flexibility, ease of use, saving, and security

practice

Personal experience, using the cloud to develop and build applications, the cost is less than 20 yuan for about half a year, and the access speed and performance are indeed excellent!

installation steps

(Take @cloudbase/js-sdk as an example)

Method 1: Introduce

#npm
npm install @cloudbase/js-sdk -S
# yarn
yarn add @cloudbase/js-sdk

Method 2: Introduce

There are two ways to introduce through CDN:

<script src="//imgcache.qq.com/qcloud/cloudbase-js-sdk/${version}/cloudbase.full.js"></script>
<script>
  const app = cloudbase.init({
    env: "your-env-id"
  });
</script>

Development steps

From a development perspective, it is really fast to use cloud development. First of all, you only need to initialize the project (take @cloudbase/js-sdk as an example)

initialization

First do the initialization: this one needs to log in to Tencent Cloud to configure it

const app = cloudbase.init({
      env: "your-env-id" // 这是你云开发对应的环境id
    appSign: 'xxxx',   // app标识
    appSecret: {
        // 版本
        appAccessKeyId: 'xxxx',
        // 密钥
        appAccessKey: 'xxxxx',
    },
});

Cloud development example>Environment>Security configuration (left menu)>Mobile application security source>Add application, after the operation is completed, three pieces of important information will be obtained smoothly!

User authentication

The second step is to log in. At this time, you need to configure login authorization to access the user page normally. Tencent Cloud Cloud provides a variety of login methods. You don't need to pay attention to the specific implementation of the login logic. Naturally, you have the most secure and reliable login solution!

Let’s take the mailbox login as an example. After turning on the front switch, you need to configure the sender

After the configuration is complete, you can configure the email application, this configuration content will appear in the email content, and provide users for email verification!

At this point, you need to add a secure domain name, and add the domain name of your application to the list of secure domain names of the cloud development instance (Web applications need to add the domain name to the list of [Environment]-[Security Configuration]-[WEB Security Domain Name], otherwise Will be identified as an illegal source.)

Then add logic in the corresponding code position

const register = (email, password) => {
    const app = cloudbase.init({
      env: 'q-tool-1griu70tb01f641a' // 您的环境id
    })
    app
      .auth()
      .signUpWithEmailAndPassword(email, password)
      .then(() => {
        // 发送验证邮件成功
      });
}

const login = (email, password) => {
    const app = cloudbase.init({
      env: 'q-tool-1griu70tb01f641a' // 您的环境id
    })
    app
      .auth()
      .signInWithEmailAndPassword(email, password)
      .then((loginState) => {
        // 登录成功
      });
}

At this point, the cloud development login is successfully connected.

Relevant information

Open cloud development: https://console.cloud.tencent.com/tcb?tdl_anchor=techsite

Product documentation: https://cloud.tencent.com/product/tcb?from=12763

Technical document: https://cloudbase.net?from=10004

Technical exchange group, latest information, follow WeChat public account [Tencent Cloud Development CloudBase]


CloudBase云开发
425 声望438 粉丝

云开发(Tencent CloudBase,TCB)是云端一体化的后端云服务 ,采用 serverless 架构,免去了移动应用构建中繁琐的服务器搭建和运维。同时云开发提供的静态托管、命令行工具(CLI)、Flutter SDK 等能力极大的降...