Skip to main content

Migrating from tcb-js-sdk

@cloudbase/js-sdk retains all core concepts of tcb-js-sdk, so you can continue using most of the logic from tcb-js-sdk. During migration, you only need to focus on the following two points:

  • Global variables
  • API migration

Migration Guide

Global Variables

The global variable exposed by tcb-js-sdk is named tcb, while @cloudbase/js-sdk has renamed it to cloudbase.

API Migration

The APIs marked as deprecated in the tcb-js-sdk documentation are no longer available in @cloudbase/js-sdk. The list is as follows:

Auth.on() - Deprecated

The Auth.on() API in tcb-js-sdk for listening to login-related events has been deprecated. @cloudbase/js-sdk provides corresponding listening APIs for each event type, as listed below: |Event Name| API | |:--:|:--:| |loginStateExpire|Auth.onLoginStateExpired()| |loginStateChanged|Auth.onLoginTypeChanged()| |refreshAccessToken|Auth.onAccessTokenRefreshed()| |anonymousConverted|Auth.onAnonymousConverted()| |loginTypeChanged|Auth.onLoginTypeChanged()|

Auth.signInAnonymously() - Replaces

The API Auth.signInAnonymously() in tcb-js-sdk for anonymous sign-in has been deprecated. @cloudbase/js-sdk provides the API AnonymousAuthProvider.signIn() to achieve the same functionality.

Auth.linkAndRetrieveDataWithTicket() - Replaces

The API Auth.linkAndRetrieveDataWithTicket() in tcb-js-sdk for converting anonymous accounts has been deprecated. @cloudbase/js-sdk provides the API User.linkWithTicket() to achieve the same functionality.

Auth.signInWithTicket() - Replaces

The API Auth.signInWithTicket() in tcb-js-sdk for custom authentication has been deprecated. @cloudbase/js-sdk provides the API CustomAuthProvider.signIn() to achieve the same functionality.

What's New

Module Architecture

tcb-js-sdk can only import the entire SDK at once, resulting in an excessively large bundled JavaScript file size, which is not user-friendly for users who only need partial Cloud Development capabilities. @cloudbase/js-sdk introduces the feature of on-demand module loading, allowing you to import specific functional modules based on your business requirements. For details, refer to the Initialization section.

More User-Friendly Syntax Hints

If you use IDEs with syntax hinting capabilities such as TypeScript or VSCode, you will experience more user-friendly syntax hints during the development process.