Run a project locally
A project on your disk, your editor, and the app reloading on a phone each time you save. Nothing here needs an account.
Create a project: lecodes init
lecodes init myapp
cd myapp
lecodes devinit writes a starter main.ts, the SDK types with a tsconfig.json (your editor completes
every global at once, offline), a CLAUDE.md for coding agents, a first flow test under tests/
and a .lecodesignore. It is safe to run again: a file that exists is kept.
lecodes init --desktop also writes an app.json that declares a desktop window — for an app that
is a desktop program first.
The rules of a project are the same as in the browser editor: no package imports, an entry point with no exports (Anatomy of a project).
Run it on a phone with hot reload: lecodes dev
lecodes devdev starts a server on your local network and prints a QR code. Scan it with the le.codes app
and the project opens on the phone, natively. From then on:
- every save recompiles and swaps the running app in place; a build error keeps the last good version running;
- the phone's
console.loglines and errors appear in the terminal; - the address is the same on every run, so the phone reconnects by itself.
Assets are served from the working tree. --port changes the port (4499), --host names the
address to advertise when the detected one is wrong, --no-qr hides the code.
Open the same project in a browser, a window, or over USB
Each flag adds a host to the same server, with the same hot reload — several at once if you like:
lecodes dev --web # in the browser, inside a device frame, with the console
lecodes dev --desktop # in a native desktop window; --fps draws the frame counter
lecodes dev --android # in the le.codes app on a phone plugged in over USB
lecodes dev --ios # in the le.codes app on a booted simulator or a plugged-in iPhone (a Mac with Xcode)--android needs no Wi-Fi and no address: the phone reaches the server through adb reverse.
Ctrl+C stops the app on the device.
--android and --ios also make a bounded check, for a script or CI:
lecodes dev --android --time 12 --png phone.pngThe app is started, the screen is saved after 12 seconds, the app is stopped, and the command exits with 1 if it crashed.
A project with server code: the local backend
A project with *.server.ts files gets its backend from dev: the server functions and a database
in .lecodes/db run on your machine. While dev runs, it is the project's one backend there —
render, desktop run, call and web dev talk to it instead of opening the database
themselves. lecodes test always keeps a database of its own, so a test never touches the data you
play with.
Call one server function from the terminal, as a device would:
lecodes call game.server.ts#createRoom Ann --as ann
lecodes call game.server.ts#joinRoom '["1234", "Bob"]' --as bob--as <name> keeps that device's session between calls. Arguments are JSON, one per word; a word
that is not JSON is a string.
For a multiplayer app, lecodes dev --bots tests/bots.flow.json adds scripted players from a flow
file to the running backend — your phone is one more player among them.
Run it in a desktop window without the server: lecodes desktop run
lecodes desktop run
lecodes desktop run --scale fit --fpsdesktop run compiles the project and opens it in the native desktop host — the full engine, 3D
included. The window's size and title come from the desktop block of app.json. The host is
downloaded on first use; lecodes desktop prints which version is in use and `lecodes desktop
update` moves it forward.
Compile the bundle: lecodes compile
lecodes compile -o app.js
lecodes compile --no-minify > app.jscompile builds the whole project into one JavaScript file — the same bundle every host runs. Without -o it goes to stdout. For a local project the bundle is self-contained:
it opens in le.codes Desktop as it is.
The project as a web page: lecodes web
dev --web shows the app as a phone would draw it. lecodes web is a different host: the app as
an ordinary web page, with the browser's own layout, text and scrolling — what a site ships. It
shows UI apps; a project's 3D and 2D scenes are not drawn there yet.
lecodes web dev # the page, reloaded on every save
lecodes web build # a folder any static hosting serves (dist/web)
lecodes web preview # serve the built folder as a hosting wouldweb dev --httpsserves the page over https with a self-signed certificate, for a phone's camera and motion sensors (a browser gives them to a secure page only). The phone warns once; accept it.web buildwrites relative URLs only, so the folder works at a domain's root and in a subfolder.- The
webblock ofapp.jsonsets the page'stitle,themeColorandlang, andurls:"hash"(the default — a route is#/product/42, which any hosting serves) or"path"(/product/42; the hosting must answer every path with the page).
Next
- Render and test — look at the app and prove it works, without a device
- Work with the platform — put the project on le.codes
- Native apps — a binary of your own for the stores and the desktop