Overview
The capability configuration feature allows developers to separate business and technical configurations from the miniapp code and manage them centrally in the cloud. This approach solves the maintenance difficulties and compliance issues caused by hardcoded configurations in the code, enabling centralized management and dynamic updates of configurations.
Key Features
- Cloud-based Configuration Management: Configuration information is stored in the cloud and supports dynamic updates
- Multiple Configuration Types: Supports four configuration types: links, booleans, numbers, and strings
- Hierarchical Configuration: Supports template configurations and instance configurations, with instance configurations having higher priority
- Multi-region Support: Supports differentiated configuration management for different regions
- Cross-platform Support: Applicable to panel miniapps, industry miniapps, and smart miniapps
Feature Modules
Developer Console Configuration Management
In the Tuya Developer Platform console, you can perform the following configuration management operations:
1. Template Configuration Creation
- Permission Restrictions: Only templates can create configurations; instances cannot create configurations directly
- Configuration Parameters: Each configuration item needs to set the following parameters:
code: Unique identifier for the configuration itemDescription: Detailed description of the configuration itemType: Data type of the configuration itemDefault Value: Default value of the configuration itemInstance Editable: Controls whether the configuration can be edited in instances
2. Configuration Types
The system supports the following four configuration types:
3. Configuration Exposure Mechanism
- Exposure Conditions: Only configurations set as "Instance Editable" will be displayed in instances
- Applicable Scope: Panel miniapps and industry application miniapps cannot be exposed to instances
- Priority: Instance configuration > Template configuration (instance configuration takes precedence, template configuration serves as fallback)
4. Multi-region Configuration
- Region Support: Supports differentiated configurations for different regions
- Configuration Method: Currently does not support one-click synchronization across multiple regions; manual configuration for each region is required
- Management Convenience: Different configuration values can be set for different regions
Configuration Management Guide
1. Creating Configurations
- Log in to Tuya Developer Platform
- Go to the miniapp management page
- Select the corresponding template miniapp
- Enter the "Capability Configuration" management page
- Click the "Add Configuration" button
- Fill in the configuration information:
- Configuration Code: English identifier, recommended to use underscore naming convention
- Configuration Description: Detailed description of the configuration's purpose and function
- Configuration Type: Select the appropriate data type
- Default Value: Set a reasonable default value
- Instance Editable Switch: Choose whether to enable editing functionality for instances based on requirements
2. Managing Configurations
2.1 Modifying Configurations
- Template configurations can be modified directly
- Instance configurations have higher priority and will override template configurations
- Configuration changes take effect the next time the miniapp is opened
2.2 Deleting Configurations
- Ensure that relevant references have been removed from the miniapp code before deleting configurations
- Deletion cannot be undone; please operate with caution
2.3 Multi-region Management
- Different regions can have different configuration values
- Each region needs to be configured separately
- It is recommended to establish configuration documentation to record configuration differences across regions
3. Usage Methods
For details, please refer to the Custom Configuration API documentation.
Ray
Native MiniApp
Important Notes
1. Compatibility
- Base library version must be >= 2.29.0
- Older versions of miniapps may not support this feature
2. Performance Optimization
- Configuration data should be loaded and cached when the application starts
- Avoid frequent calls to the
ty.getCustomConfig()interface - Set reasonable default values for configurations to ensure the miniapp can run normally even when network exceptions occur
3. Security Considerations
- Sensitive information (such as keys, passwords) should not be passed through custom configurations
- Configuration values are transmitted in plain text; please pay attention to data security
- It is recommended to encrypt important configurations