Skip to main content

Initialize the SDK

Login occurs on the client side. After the mini program is connected to CloudBase, it automatically completes authentication based on UID.

Therefore, the js-sdk is provided here for authentication on the Web.

SDK Installation

Import @cloudbase/js-sdk@2.x in your project

npm install --save @cloudbase/js-sdk

Initialize the SDK

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

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

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

Adding Security Domains (Optional)

Web applications must add their domain names to the CloudBase/Security Source List; otherwise, they will be identified as unauthorized sources:

Adding Security Domains