@magneticjs/cli
v0.1.7
Published
Magnetic CLI — build, dev, and deploy server-driven UI apps
Maintainers
Readme
@magneticjs/cli
Build, develop, and deploy Magnetic server-driven UI apps.
Installation
npm install -g @magneticjs/cliThis also downloads the magnetic-v8-server binary for your platform via postinstall.
Commands
magnetic dev
Start a local development server with hot rebuild on file changes.
cd my-app
magnetic dev # http://localhost:3003
magnetic dev --port 4000 # custom port
magnetic dev --dir ./my-app # specify app directoryWhat happens:
- Scans
pages/for TSX page components - Detects
server/state.tsfor business logic - Auto-generates the V8 bridge (route map + state wiring)
- Bundles with esbuild into a single IIFE
- Starts
magnetic-v8-serveron the specified port - Watches for changes, rebuilds + restarts on save
magnetic build
Generate the production bundle without starting a server.
magnetic build --dir ./my-app
magnetic build --dir ./my-app --minify --verboseOutput: dist/app.js (~15KB typical)
magnetic push
Build and deploy to a Magnetic platform server.
magnetic push --dir ./my-app --server https://platform.magnetic.app --name my-appOr configure in magnetic.json:
{
"name": "my-app",
"server": "https://platform.magnetic.app"
}Then just: magnetic push
How It Works
The CLI is a build tool, not a runtime. It:
- Scans your
pages/directory and maps filenames to routes - Generates a bridge file that wires pages + state + router
- Bundles everything into a single JS file for the V8 engine
- The Rust V8 server executes this bundle to render JSON DOM descriptors
You write: pages, components, state CLI generates: bridge, bundle Rust server runs: V8 + HTTP + SSE
File Conventions
| File | Route |
|------|-------|
| pages/IndexPage.tsx | / |
| pages/AboutPage.tsx | /about |
| pages/SettingsPage.tsx | /settings |
| pages/[id].tsx | /:id (dynamic) |
| pages/NotFoundPage.tsx | * (catch-all) |
Server Binary
The Rust binary (magnetic-v8-server) is automatically downloaded during
npm install. If the download fails, you can build from source:
cd rs/crates/magnetic-v8-server
cargo build --releaseSupported platforms: macOS (ARM64, x64), Linux (x64, ARM64)
License
MIT
