a reactive (signals based) hypermedia web framework (wip)
stormlightlabs.github.io/volt/
hypermedia
frontend
signals
1# CLI
2
3⚠️ This CLI is unreleased as of writing. The documentation may change before the CLI is published in v0.6.0.
4
5The VoltX.js CLI provides tools for creating and managing VoltX.js applications. Use it to scaffold new projects, run development servers, build for production, and download framework assets.
6
7## Installation
8
9The CLI is available as `create-voltx` on npm:
10
11```bash
12# Use with pnpm
13pnpm create voltx my-app
14
15# Use with npm
16npm create voltx@latest my-app
17
18# Use with npx
19npx create-voltx my-app
20```
21
22For ongoing development commands, install the CLI in your project:
23
24```bash
25pnpm add -D create-voltx
26```
27
28## Commands
29
30### `init`
31
32Create a new VoltX.js project with an interactive template selector.
33
34```bash
35# Interactive mode - prompts for project name and template
36pnpm create voltx
37
38# Specify project name
39pnpm create voltx my-app
40
41# Using the voltx command
42voltx init my-app
43```
44
45**Templates:**
46
47- **Minimal** - Basic VoltX.js app with a counter demo
48- **With Router** - Multi-page app with client-side routing
49- **With Plugins** - Demonstration of all VoltX.js plugins
50- **Styles Only** - HTML + CSS using VoltX.js styles without the framework
51
52The init command:
53
54- Creates project directory
55- Generates HTML, CSS, package.json, and README
56- Downloads latest VoltX.js assets from CDN
57- Sets up development scripts
58
59**Generated Structure:**
60
61```sh
62my-app/
63├── index.html # Main HTML file
64├── styles.css # Custom styles
65├── package.json # Project configuration
66├── README.md # Getting started guide
67├── voltx.min.js # VoltX.js framework
68└── voltx.min.css # VoltX.js base styles
69```
70
71### `dev`
72
73Start a Vite development server for your VoltX.js project.
74
75```bash
76voltx dev
77```
78
79**Options:**
80
81- `-p, --port <port>` - Port to run the dev server on (default: 3000)
82- `-o, --open` - Open browser automatically
83
84**Examples:**
85
86```bash
87# Start dev server on default port (3000)
88voltx dev
89
90# Use custom port
91voltx dev --port 8080
92
93# Open browser automatically
94voltx dev --open
95```
96
97The dev server provides:
98
99- Hot module replacement (HMR)
100- Fast refresh for development
101- Automatic browser reload
102- HTTPS support (via Vite)
103
104### `build`
105
106Build your VoltX.js project for production.
107
108```bash
109voltx build
110```
111
112**Options:**
113
114- `--out <dir>` - Output directory (default: dist)
115
116**Examples:**
117
118```bash
119# Build to default dist/ directory
120voltx build
121
122# Build to custom directory
123voltx build --out public
124```
125
126The build command:
127
128- Minifies HTML, CSS, and JavaScript
129- Optimizes assets for production
130- Generates source maps
131- Creates optimized bundle
132
133### `download`
134
135Download VoltX.js assets (JS and CSS) from the CDN.
136
137```bash
138voltx download
139```
140
141**Options:**
142
143- `--version <version>` - VoltX.js version to download (default: latest)
144- `--no-js` - Skip downloading JavaScript file
145- `--no-css` - Skip downloading CSS file
146- `-o, --output <dir>` - Output directory (default: current directory)
147
148**Examples:**
149
150```bash
151# Download latest JS and CSS
152voltx download
153
154# Download specific version
155voltx download --version 0.5.0
156
157# Download only CSS
158voltx download --no-js
159
160# Download to custom directory
161voltx download --output assets
162```
163
164This command downloads minified assets from the jsDelivr CDN.
165
166## Workflows
167
168### Creating a New Project
169
170```bash
171# Create new project
172pnpm create voltx my-app
173
174# Navigate to project
175cd my-app
176
177# Install dependencies
178pnpm install
179
180# Start dev server
181pnpm dev
182```
183
184### Development
185
186```bash
187# Start dev server (watches for changes)
188pnpm dev
189
190# In another terminal, run tests if available
191pnpm test
192```
193
194### Production Build
195
196```bash
197# Build for production
198pnpm build
199
200# Preview production build locally
201npx vite preview --outDir dist
202```
203
204### Updating VoltX.js Assets
205
206```bash
207# Download latest version
208voltx download
209
210# Or download specific version
211voltx download --version 0.5.1
212```
213
214## Project Scripts
215
216All generated projects include these npm scripts:
217
218```json
219{
220 "scripts": {
221 "dev": "voltx dev",
222 "build": "voltx build"
223 }
224}
225```
226
227Run them with your package manager:
228
229```bash
230pnpm dev
231pnpm build
232```
233
234## Templates
235
236### Minimal
237
238A basic VoltX.js application demonstrating:
239
240- Declarative state with `data-volt-state`
241- Reactive bindings
242- Event handlers
243- Counter example
244
245### With Router
246
247A multi-page application featuring:
248
249- Client-side routing with History API
250- Multiple routes (home, about, contact, 404)
251- Navigation with `data-volt-navigate`
252- Route matching with `data-volt-url`
253
254### With Plugins
255
256A comprehensive demo showcasing:
257
258- Persist plugin (localStorage sync)
259- Scroll plugin (smooth scrolling)
260- URL plugin (URL parameter sync)
261- Surge plugin (animations)
262- Navigate plugin (routing)
263
264Best for: Learning all VoltX.js features, reference implementation.
265
266### Styles Only
267
268HTML and CSS using VoltX.js styles without the reactive framework:
269
270- VoltX.js CSS utilities
271- Semantic HTML
272- No JavaScript required
273
274## Configuration
275
276### Vite Configuration
277
278The CLI uses Vite as the dev server and build tool. To customize Vite, create a `vite.config.js` in your project root:
279
280```js
281import { defineConfig } from 'vite';
282
283export default defineConfig({
284 server: {
285 port: 3000,
286 },
287 build: {
288 outDir: 'dist',
289 },
290});
291```
292
293See the [Vite documentation](https://vitejs.dev/config/) for all available options.