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

bash
lecodes init myapp
cd myapp
lecodes dev

init 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

bash
lecodes dev

dev 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.log lines 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:

bash
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:

bash
lecodes dev --android --time 12 --png phone.png

The 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:

bash
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

bash
lecodes desktop run
lecodes desktop run --scale fit --fps

desktop 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

bash
lecodes compile -o app.js
lecodes compile --no-minify > app.js

compile 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.

bash
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 would
  • web dev --https serves 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 build writes relative URLs only, so the folder works at a domain's root and in a subfolder.
  • The web block of app.json sets the page's title, themeColor and lang, and urls: "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