Skip to content

Quick Start

This chapter will guide you through the installation and startup of comp-hub, which takes no more than 5 minutes.

Requirements

  • Node.js >= 16.0.0
  • npm >= 8.0.0

Supported Frameworks

FrameworkVersionStatus
Vue2.x✅ Supported
Vue3.x✅ Supported
React-⏳ Planned

Installation

Install comp-hub CLI globally. After installation, you can use the comphub command directly:

bash
npm install comp-hub@latest -g

Method 2: Local Dev Dependency Installation

Install only in the current project, suitable for team collaboration scenarios:

bash
npm install comp-hub@latest -D

Start Service

Start after Global Installation

Execute in the project directory:

bash
comphub

Start after Local Installation

If you installed locally with -D, you need to execute via npx:

bash
npx comphub

After successful startup, the terminal will display output similar to the following:

✓ comp-hub v0.28.4
✓ Project registered (hash: 9de6965c)

   ██████╗  ██████╗  ███╗   ███╗ ██████╗       ██╗  ██╗ ██╗   ██╗ ██████╗
  ██╔════╝ ██╔═══██╗ ████╗ ████║ ██╔══██╗      ██║  ██║ ██║   ██║ ██╔══██╗
  ██║      ██║   ██║ ██╔████╔██║ ██████╔╝      ███████║ ██║   ██║ ██████╔╝
  ██║      ██║   ██║ ██║╚██╔╝██║ ██╔═══╝       ██╔══██║ ██║   ██║ ██╔══██╗
  ╚██████╗ ╚██████╔╝ ██║ ╚═╝ ██║ ██║           ██║  ██║ ╚██████╔╝ ██████╔╝
   ╚═════╝  ╚═════╝  ╚═╝     ╚═╝ ╚═╝           ╚═╝  ╚═╝  ╚═════╝  ╚═════╝

  Version  0.28.4
  Project  /home/user/projects/housing/vue2
  Hash     9de6965c
  Port     5478

  URL      http://localhost:5478/9de6965c/main/

  ─────────────────────────────────────────────

  comphub status                View all projects
  comphub stop    9de6965c      Stop current project
  comphub stop    --all         Stop all projects
  comphub kill                  Shutdown master

Use a browser to access the displayed URL to enter the comp-hub platform.

CLI Command Line Parameters

You can also configure startup options via command line parameters:

bash
comphub [options]

Parameter Description:

ParameterShortTypeDefaultDescription
--port-pnumber5478Service port
--dir-dpath"./"Resource directory relative path

| --version | -v | - | - | Show version number | | --help | -h | - | - | Show help information |

Usage Examples:

bash
# Start with specified port
comphub -p 8080

# Specify resource directory
comphub -d ./src

# View version number
comphub -v

# View help information
comphub -h

Configuration

To specify the component directory or configure custom proxy rules, create a .comphub.json or .comphub.js file in the project root directory:

Configuration File Format

JSON Format (.comphub.json):

json
{
  "dir": "./src",
  "allowDebug": false
}

JS Format (.comphub.js):

javascript
module.exports = {
  dir: './src',
  allowDebug: false
}

Configuration Items

Configuration ItemTypeDefaultDescription
dirstring"./"Relative path to the component code root directory. Only this directory and its subdirectories can be operated during upload/download
allowDebugbooleanfalseWhether to allow debug mode
proxyobject-Custom proxy rules, same format as http-proxy-middleware options

Configuration File Loading Priority

  1. Try to load .comphub.json first
  2. If the JSON file does not exist, try to load .comphub.js
  3. If neither exists, use default configuration

Configuration Priority

Configuration value priority from high to low:

  1. Command line parameters (e.g., -d ./src)
  2. Configuration file (.comphub.json or .comphub.js)
  3. Default configuration

Next Steps

After the service starts, you can:

Components uploaded by users are open source