blocklet add
Adds a blocklet as a component dependency to the current blocklet project. This command allows you to build complex, composite applications by assembling various blocklets together.
This command fetches the metadata of the specified component (either from a URL or a Blocklet Store), adds it to the components array in your blocklet.yml file, and checks for circular dependencies to ensure a valid project structure.
For a high-level guide on creating composite applications, see Compose Components.
How It Works#
The blocklet add command follows a clear process to add a new component to your project:
Command Usage#
blocklet add <name | url> [options]Parameters#
Name | Type | Description |
|---|---|---|
`<name | url>` |
|
Options#
Option | Description |
|---|---|
| Specifies a custom title for the component. If not provided, the title from the component's metadata will be used. |
| Defines a custom mount point (URL path) for the component. If not set, a URL-friendly version of the component's name is used (e.g., |
| Specifies the URL of the Blocklet Store to fetch the component from. This overrides any store configured globally or in the current profile. |
| Uses a specific configuration profile from your Blocklet CLI settings. Defaults to |
Examples#
Add a component from the default Blocklet Store#
This command fetches the latest version of the @blocklet/did-connect blocklet and adds it as a component.
blocklet add @blocklet/did-connectAfter running the command, your blocklet.yml will be updated with a new entry in the components section:
# blocklet.yml
name: my-app
version: 1.0.0
# ... other fields
components:
- name: did-connect
title: DID Connect
mountPoint: /connect
source:
store: https://store.arcblock.io
name: '@blocklet/did-connect'
version: 'latest'Add a component with a custom mount point and title#
You can customize how the component is integrated into your project.
blocklet add my-component --title "My Custom Component" --mount-point "/custom-path"This will result in the following configuration in blocklet.yml:
# blocklet.yml
components:
- name: my-component
title: My Custom Component
mountPoint: /custom-path
source:
store: https://store.arcblock.io # or your configured store
name: my-component
version: 'latest'Add a component from a specific URL#
If you have a direct link to a component's metadata, you can use it directly. This is useful for development or private components not published to a store.
blocklet add https://private-repo.com/my-component/blocklet.jsonYour blocklet.yml will be updated accordingly:
# blocklet.yml
components:
- name: my-component # Name is read from the metadata file
title: My Component
mountPoint: /my-component
source:
url: https://private-repo.com/my-component/blocklet.jsonOnce you have added a component, you may need to remove it later. To learn how, proceed to the blocklet remove documentation.