@styleui/cli
v1.0.38
Published
The local AST mutation daemon for StyleUI
Readme
@styleui/cli
The local AST mutation daemon and automated configuration setup utility for StyleUI.
This package provides the styleui command-line tool, which manages project initialization and controls the local WebSocket development daemon. The daemon synchronizes visual mutations from the StyleUI chrome extension back into your React/Next.js/Vite codebase in real-time.
Installation
You can install @styleui/cli globally to have the styleui command always available:
npm install -g @styleui/cliAlternatively, you can run the CLI on-demand without prior installation using npx:
npx styleui <command> [options]Commands & Usage
1. styleui init
Sets up the integration of StyleUI within your frontend project.
styleui initWhat it does:
- Detects Your Environment: Checks
package.jsonand config files to determine if your project is running Next.js or Vite. - Installs Integration Plugins:
- Installs
@styleui/next-pluginas a devDependency in Next.js projects. - Installs
@styleui/vite-pluginas a devDependency in Vite projects.
- Installs
- AST Config Wrapping: Uses AST parsing (
recast) to non-destructively wrap your existingnext.config.js/mjs/tsorvite.config.ts/js/mjs/cjsto enable StyleUI source-tracing compiling:- For Next.js: Wraps the config object using
withStyleUI. - For Vite: Adds
withStyleUI()to the plugins array.
- For Next.js: Wraps the config object using
2. styleui dev
Launches the StyleUI development synchronization engine.
styleui dev [options]What it does:
- License Gatekeeping: Prompts for a valid StyleUI License Key if not already authenticated. Saves the authenticated key locally at
~/.styleuikey. - Spawns WebSocket Server: Starts the mutation daemon locally (by default on port
8899). - Auto-Spawns Dev Server: Detects the package manager (
npm,yarn,pnpm, orbun) and spawns the framework dev server (e.g. runningnpm run dev) in a concurrent child process, sharing standard I/O. - Launches Browser: Automatically launches your browser pointing to
http://localhost:3000(or your local address) to kickstart visual editing.
Options:
-p, --port <number>: Port to run the WebSocket daemon server on. (Default:8899)-b, --browser <type>: Target browser to spawn. Options:"chrome","edge","auto". (Default:"auto")-h, --help: Display command usage details.
Shell Help Output
To see all commands and globally available flags, run:
styleui --helpOutput:
Usage: styleui [options] [command]
StyleUI Daemon - Local AST and WebSocket Engine
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
init Automatically inject @styleui/next-plugin and wrap the Next.js config
dev [options] Start both the WebSocket daemon and the Next.js dev server concurrently
help [command] display help for commandTo see detailed options for the dev command, run:
styleui dev --helpOutput:
Usage: styleui dev [options]
Start both the WebSocket daemon and the Next.js dev server concurrently
Options:
-p, --port <number> port to run the WebSocket server on (default: "8899")
-b, --browser <type> Browser to launch ("chrome", "edge", "auto") (default: "auto")
-h, --help display help for commandTroubleshooting
Port Conflicts
If you see the error:
❌ Port 8899 is already in use.
You can run the daemon on a custom port:
styleui dev -p 9000Make sure to specify this same port in the StyleUI browser extension settings.
Dev Server Exited
If your React/Next.js dev server exits immediately upon run:
- Ensure you have run dependency installation (
npm install,pnpm install, etc.). - Verify that the port utilized by your Next.js/Vite application (typically
3000or5173) is not already bound by another process.
