Skip to main content

SDK Initialization

Version Notes
  • Login Authentication (v2) applies to the @cloudbase/js-sdk@2.x version.
  • If the SDK version you are using is 1.x, see Login Authentication (v1)
  • v2 version temporarily does not support the Official Account login method. If you need to use this method, please use the v1 version

This document will describe based on the V2 version.

Installing the SDK

In your project, import @cloudbase/js-sdk@2.x.

npm install --save @cloudbase/js-sdk

Initialize the SDK

import cloudbase from "@cloudbase/js-sdk";

const app = cloudbase.init({
env: "your-env-id"
});

// Obtain the auth instance
const auth = app.auth();

Add secure domain (optional)

Web applications need to add domains to CloudBase/Security Sources List; otherwise, they will be identified as illegal sources.

Add secure domain