Prerequisite

  • Register with the Tuya IoT Development Platform.

  • Install the Docker environment. We can start the environment using Docker-compose. For more information about Docker installation, see the Docker website.

    Open a command line and run docker -v. If the output returns the docker version, Docker is installed correctly.

    docker -v
    Docker version 20.10.5, build 55c4c88
  • Install Node.js 14 or later.

    Open a command line and run node -v. If the output returns the Node.js version, Node.js is installed correctly.

    node -v
    v14.17.1
  • Install Git to download the environment and installation script.

    Open a command line and run git --version. If the output returns the Git version, Git is installed correctly.

    git --version
    git version 2.30.1 (Apple Git-130)

TIP

(Optional) We recommend you install the powerful JavaScript package manager Yarn as an alternative to npm. You can install Yarn 1.5 or later and run the command yarn --version to verify the Yarn version.

Procedure

Try out the complete development process in 15 minutes. You will go through the following steps:

graph LR; A[Set Up Environment] --> B[Create SaaS] --> C[Develop Micro Applications] --> D[Verify SaaS]

Step 1: Install environment

Supported operating systems: CentOS Linux, Windows, and macOS.

1. Download installation script

Go to the directory where you want to clone the repository and run the following command.

git clone https://github.com/tuya-sat/sdf-deploy.git
# sdf-deploy directory
├── LICENSE
├── README.md
├── docker-compose
│ ├── README.md
│ └── docker-compose.yml
│ └── redis

2. Configure App Key and Secret Key

  1. Open the SaaS No-Code Platform and get the developer App Key and Secret Key.

    TIP

    Since the SaaS No-Code Platform is in beta testing, you can request access to the platform as instructed in Register as a developer.

  2. After you download the installation script sdf-deploy, go to the directory docker-compose. Create the configuration file .env and configure the developer App Key and Secret Key.

    cd sdf-deploy/docker-compose/ # Go to the docker-compose directory.
    cp _env .env # Copy a .env file from _env.
    vi .env # Edit the .env file.
    # developer Configuration information
    DEVELOPER_CODE=Developer App Key
    DEVELOPER_KEY=Developer Secret Key
    # (Optional) CustomAPI domain name, for example, https://api-gateway.com
    CUSTOM_API_URL=
  3. Install and configure sdf-cli command-line tool

    yarn global add @tuya-sat/sdf-cli

    Configure sdf-cli. Enter the developer App Key and Secret Key.

    sdf config

    Enter App Key, Secret Key, and endpoint (optional) one after another. The endpoint should be an online environment.

3. Start the service

In the current directory (sdf-deploy/docker-compose), start the service using docker-compose up.

# Make sure Docker is running before starting the service.
docker-compose up

Visit 127.0.0.1:3000 to verify that the environment is set up.

Welcome page

Step 2: Create SaaS

  1. Create SaaS Open SaaS No-Code Platform. Create and configure a SaaS.

    • We recommend you choose Create project for Link Cloud Project. A new cloud project will be created and linked with the SaaS automatically.

    • Choose Partially Managed for Hosting Type. The Partially Managed SaaS supports custom development.

    • When you are configuring your SaaS, Custom Domain Name, Page Title (in Chinese and English), and Tenants and Adminsare required.

      Create SaaS

  2. Verify SaaS Mapping the SaaS domain name to the local computer.

    127.0.0.1 {Your SaaS domain name}

    INFO

    To open your SaaS, enter http://{Your SaaS domain name}:3000 in a browser and enter the admin username and password. Note that you should use http instead of https in the browser address bar.

Step 3: Develop micro application

  1. Quickly create a micro application based on the demo. During the creation of a micro application in the command line, when you are asked to enter the package name, micro application name, and description, you can input enter to use the default values and edit them in code.

    npx @tuya-sat/create-micro-app@latest demo -t react-ts

    Initialization

  2. Debug micro application

    Open the demo project to debug the code. Since you are working on a demo, for simplicity, you can skip this step. For more information, see Develop and Debug Desktop Micro Application.

    # Micro application directory
    ├── README.md
    ├── _locales
    │ ├── en.json
    │ └── zh-CN.json
    ├── logo.svg
    ├── manifest.json
    ├── micro.config.js
    ├── mock
    │ └── index.json
    ├── package.json
    ├── public
    │ ├── favicon.ico
    │ └── index.html
    ├── src
    │ ├── App.css
    │ ├── App.jsx
    │ ├── api
    │ │ ├── index.js
    │ │ ├── req.js
    │ │ ├── res.js
    │ │ └── urls.js
    │ ├── components
    │ │ ├── Button
    │ │ ├── HelloTemplate
    │ │ └── Table
    │ ├── hooks
    │ │ └── index.js
    │ ├── index.css
    │ ├── index.jsx
    │ ├── lang
    │ │ ├── en.js
    │ │ ├── index.js
    │ │ └── zh.js
    │ ├── pages
    │ │ ├── index.jsx
    │ │ └── index.module.less
    │ └── public-path.js
    └── yarn.lock
  3. Publish micro application

    Build the project in the root directory of the micro application you have just created.

    yarn build

    Publish the project using sdf-cli.

    sdf publish

    Yarn

    After the micro application is published, you can find it on the SaaS No-Code Platform.

Step 4: Verify SaaS

1. Add micro application

  1. Choose My SaaS from the left navigation pane. Click Configure in the Operation column and choose SaaS Features.

  2. Click Select Functional Components and choose the Private tab.

  3. Find the micro application you just published. Choose Latest from the drop-down list and click OK. Then, this micro application will be integrated into the SaaS.

    Add microapp

2. Verify the SaaS

Open your SaaS. You will find the newly added micro application shown in the menu.