Getting started
Requirements
- Rust 1.99 or newer (rustup).
- Node.js 22 or newer, to develop and build the frontend.
- pnpm (recommended) or npm. If pnpm is installed,
moltn newuses it.
To see what moltn finds on your machine, run moltn doctor inside a project.
Install the moltn command
From the moltn repository:
bash
cargo install --path crates/moltn-cliThe command goes to ~/.cargo/bin, which is already on your PATH if you use rustup.
Create a project
bash
moltn new my-app # Vue by default
moltn new my-app --front react
moltn new my-app --front sveltemoltn new writes the project, installs the frontend dependencies, then compiles the application once (one to a few minutes depending on the machine). When it is done, the project is ready:
bash
cd my-app
moltn devOpen the address moltn prints:
➜ moltn http://127.0.0.1:3000 (Ctrl+C to stop)What a project contains
my-app/
Cargo.toml
build.rs # reads web/src/pages/ at compile time
src/main.rs # server: #[page] loaders, configuration
web/
package.json
vite.config.ts # plugins: vue() | react() | svelte(), inertia(), moltn()
src/
app.ts # createInertiaApp()
pages/
index.vue # → /
about.vue # → /about
generated/
moltn.ts # generated: props types and route()The development loop
While moltn dev runs:
- edit a frontend file (
.vue,.tsx,.svelte, CSS): the page updates without reloading; - edit Rust code,
Cargo.toml, or add / remove a page: moltn recompiles and restarts the application on its own;web/src/generated/moltn.tsis updated on restart; - on a compile error, moltn waits for the next change;
- Ctrl+C stops everything and leaves no process behind.
Next
- Add pages and their data: Pages and loaders.
- Type props and links: Types and routes.
- Build the final binary: Production.