create-magnetic-app
v0.1.5
Published
Scaffold a new Magnetic server-driven UI app
Maintainers
Readme
create-magnetic-app
Scaffold a new Magnetic server-driven UI application.
Usage
npx create-magnetic-app my-app
cd my-app
magnetic devTemplates
todo (default)
Full todo app with state management, multiple pages, and components:
npx create-magnetic-app my-app --template todoblank
Minimal app with a single page:
npx create-magnetic-app my-app --template blankGenerated Structure
my-app/
pages/ ← TSX page components (filename = route)
IndexPage.tsx → /
AboutPage.tsx → /about
NotFoundPage.tsx → * (catch-all)
components/ ← shared TSX components
server/
state.ts ← business logic (state, reducer, view model)
public/
magnetic.js ← client runtime (~1.5KB gzipped)
style.css ← app styles
magnetic.json ← app config
tsconfig.json ← IDE/TypeScript support
README.mdWhat You Edit
pages/*.tsx— page components (auto-routed)components/*.tsx— shared componentsserver/state.ts— all business logicpublic/style.css— styles
What You Never Edit
public/magnetic.js— client runtime (provided by framework)- Generated bridge code (auto-generated by CLI)
- Bundle output (
dist/app.js)
For AI Agents
- Scaffold:
npx create-magnetic-app <name> - Edit only:
pages/,components/,server/state.ts,public/style.css - Run:
magnetic dev→ opens athttp://localhost:3003 - Actions:
onClick="action_name"dispatches toreduce()instate.ts - Forms:
onSubmit="action_name"collects FormData as payload - Navigation:
<Link href="/path">for client-side routing - State shape:
initialState()→reduce(state, action, payload)→toViewModel(state)→ passed as page props
License
MIT
