Set up environment

Prerequisites

  • Before building a miniapp, get your Node.js environment ready. Go to the Node.js website and download the installer.

Install editor

Before you develop a panel miniapp, download and install the following recommended editors as needed:

  • Visual Studio Code (recommended): supports common built-in features, such as formatting and navigation. This editor is subject to a high level of community engagement.
  • WebStorm: Highly integrated IDE.
  • Sublime Text: a lightweight editor.

Install app

If you want to install a specific app version, you can submit a ticket on the Tuya Developer Platform to request further support.

iOS:

Go to App Store > SmartLife, or search for SmartLife on App Store for iPhones, and download the app.

Android:

Go to Google Play > SmartLife, or search for SmartLife on app stores for Android, and download the app.

Install Tuya MiniApp IDE

Tuya MiniApp IDE can be used to create your miniapp project, and develop, debug, and upload the miniapp.

Go to Tuya MiniApp IDE and download the latest version.

Install NVM

Node.js version manager (NVM) helps you manage multiple Node.js versions. If this is your first installation, set up the environment variable as per the instruction.

  1. Open the Terminal.

  2. Install the NVM.

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
  3. Enter nvm -v to confirm that NVM is installed as expected. If a version number is returned, the installation is successful. Make sure you are using Node.js v18.0.0 or later. If the error nvm: command not found is returned, follow the instructions in FAQs to fix the error.

  4. Enter nvm install 18.20.8 to install Node.js v18.20.8.

  5. (Optional) Run the command nvm use to switch among Node.js versions. We recommend that you install Node.js v18.20.8 or later.

    nvm use 18.20.8

Install Yarn

If you have installed Yarn, or used Node.js Package Manager (npm), performant npm (pnpm), or other dependency manager tools, you can skip this section.

  1. Open the Terminal.

  2. Enter npm install -g yarn to install Yarn.

  3. (Optional) Enter yarn -v to confirm that Yarn is installed as expected.

Create your Tuya account

Register an account of the Tuya Developer Platform.

Initialize project

You must register an account with the Tuya Developer Platform and use this account to log in to the Tuya MiniApp Developer Platform before you can create a miniapp.

  1. Log in to the Tuya MiniApp Developer Platform to see the page that lists existing miniapps.

  2. Click Create on this page.

  3. Set the name, logo, type, and other required information about the miniapp, and click OK.

Develop and debug

  1. Open Tuya MiniApp IDE, log in to it with the account of the Tuya Developer Platform, and then create a miniapp project.
  2. Set the project path, project name, and associated miniapp as instructed, and click OK to open the project.
  3. To link the project with a smart miniapp, you must have the necessary developer permissions on the Tuya MiniApp Developer Platform. Then, when you create or import a miniapp project in Tuya MiniApp IDE, you can link the project with the miniapp created on the Tuya MiniApp Developer Platform. This allows you to develop, debug, and upload the code.

Write code

Your project template is automatically initialized in the project path of Tuya MiniApp IDE. You can use the code editor to open the project and start programming.

  • For more information about the directory structure and file types of the miniapp, see Framework.
  • For more information about the basic components of the miniapp, see Components.

Preview and debug

During the development in the IDE, you can preview the miniapp with the emulator in the left pane.

The emulator does not support all APIs. Therefore, you must click Remote Debugger in the top menu bar to preview and debug the miniapp.

Upload program

At the end of the development, click Upload in Tuya MiniApp IDE to upload the local program to the cloud.

The uploaded version will then appear on the Tuya MiniApp Developer Platform.

Test miniapp

Step 1: Install app

The tester must get the app installation package from the app developer to install the app for testing. The app developer must have integrated the miniapp capabilities into the app. The base library version and Kit package version that are bound with the app must be compatible with the miniapp to be tested.

Step 2: Add the test account to the miniapp project and allowlist

Go to Tuya MiniApp Developer Platform > Members and add the test account to the project. Therefore, the tester can access the miniapp project by using this account.

You must also configure the Distribution module as required and add the test account to the allowlist.

For more information, see Tuya MiniApp Developer Platform > Trial QR Code.

Step 3: Generate trial QR code

  1. Go to Tuya MiniApp Developer Platform > Versions, and set the target miniapp version to the trial version.
  2. Click Trial QR Code for the version.
  3. Configure the QR code to enable automatic navigation to a specified page from the miniapp. You can also keep the default settings and click OK.
  4. Scan the QR code and test the miniapp.

Compliance requirements

Your miniapps must meet security compliance requirements. Tuya performs security checks for the target domain names and request paths for the miniapps.

To make the following API requests or load static resources, you must configure respective domain names at Tuya MiniApp Developer Platform > Development. Otherwise, an error message might be returned when you make an API request or load static resources.

Target APIConfigured At
ty.request()Tuya MiniApp Developer Platform > Development > Server Domain Names Across Data Centers
ty.uploadFile()Tuya MiniApp Developer Platform > Development > Server Domain Names Across Data Centers
ty.downloadFile()Tuya MiniApp Developer Platform > Development > Server Domain Names Across Data Centers
Static resourcesTuya MiniApp Developer Platform > Development > Static Resources Across Data Centers

Add the domain names that are accessible by ty.request(), ty.uploadFile(), and ty.downloadFile() to Tuya MiniApp Developer Platform > Development > Server Domain Names Across Data Centers.

To enable these API requests, the trustable domain names can vary, depending on the different data centers to which your target apps will be distributed. Note: Do not include the root path / in the trustable domain names to be added.

To view the data centers to which your target apps will be distributed, go to Tuya MiniApp Developer Platform > Distribution.

Add the domain names of the static resources specified in the code package of a miniapp to Tuya MiniApp Developer Platform > Development > Static Resources Across Data Centers. These domain names can vary, depending on the different data centers to which your target apps will be distributed.

Note: Do not include the root path / in the trustable domain names to be added.

Submit for review and release

  1. Log in to the Tuya MiniApp Developer Platform and click the target miniapp to go to Versions.
  2. On the Dev Versions tab, find the target version and click Submit for Review.
  3. Then, this version is moved to the Review Versions tab and appears with the review status.
  4. The approved version is moved to the Official Version tab, where you can start or pause this version. You can click the Start button to make this version available to users, or click Pause to make it unavailable to users.
Version typeDescriptionAvailable button
Development versionEach uploaded version is an independent development version.Submit for Review, Delete
Trial version(Optional) Before an official version becomes generally available, you can set this version to a trial version and allow authorized members to test this version.Set as trial version
Review versionA development version is submitted for review and becomes this version. If a version does not pass the review, the version needs to be returned for modification based on the reason for rejection.Available buttons vary, depending on different review states:
- Reviewing: Cancel Review
- Passed: Request Release
- Rejected: Cancel Review
Official versionThe released official version is generally available to all users.Start, Pause

Miniapp distribution

  • Distribute a miniapp to the specified app to make it available on that app. Go to Tuya MiniApp Developer Platform > Distribution and add the target app. Only OEM apps under your Tuya Developer Platform account are eligible for miniapp distribution.
  • After adding the deployed MiniApp, you need to select the corresponding deployment region. For example, for MiniApp to be deployed in the US region, you need to select the US data center. If none are selected, access will not be available anywhere.
  • The distribution step is unnecessary for panel miniapps.
  • After distributing a miniapp, configure its entry point on the Tuya Developer Platform. See How to configure tab pages.

Configure custom tab pages

  • Tuya offers various features to enhance your app experience. You can configure a miniapp entry point on the Smart tab page or customize a tab page with a miniapp.
  1. Configure a miniapp entry point on the Smart tab page. See Smart Configuration.

  2. Customize a tab page.

    Choose your app on the IoT Development Platform. Click Detailed Settings.

    Choose Page > Manage Tab Pages > Add Miniapp.

Choose the target miniapp, upload its icon, and set the name. Then, you can configure a miniapp entry point on your custom tab page.

See more configurations.