Concepts
Luxel looks like React when you write a view. It works very differently when the page runs. This page explains the model in the order a page lives: build, request, browser, update.
The short version
| — | React / Next.js | Luxel |
|---|---|---|
| Your component code runs | On the server per request (SSR) and again in the browser (hydration) | Once, at build time, in Node |
| What the browser downloads | Your app's JavaScript bundle | One shared runtime, the same file for every app |
| Who computes totals, pages, formats | Often the browser | Always the server |
| How a page becomes interactive | Hydration: re-run components, attach handlers | Resume: find the painted slots, listen by delegation |
| How an update reaches the page | New state, re-render, DOM diff | A delta: only the affected slots change |
Compiled projection
luxel build runs each view once, in Node, and writes:
- an HTML template: the structure and the fixed texts, already written. Each hole that shows data is marked with a slot index (data-s="‹index>"). It is public, hashed and cacheable. It contains no user data.
- a slot map: for each index, the zone it belongs to, its kind (text, an attribute from a closed list, a status, a collection…), the state path it shows and how to escape it. Item templates of collections live here too.
- a VSA manifest: the view's zones, events and the runtime capabilities it needs. VSA (Visual State Atlas) is the open protocol between server and runtime.
- the server-only event contract (.luxel/events.json) and the generated handler types (.luxel/server.ts). These stay on the server.
The build writes them under outDir: luxel.config.json, manifests/, pages/, assets/ (public) and .luxel/ (server-only).
Slots and the slot map
A slot is one place in the template that shows server data: a text, a money amount, a state class, an input's value, a number of a chart, a collection. The slot map ties each slot index to a state path of the contract.
The path (contacts.summary) is a server-side name. It is never published. The browser only knows slot indices and zone ids.
Per request: fill, do not render
When a page is requested, the server:
- runs your defineLoad to read the view's state, with its version;
- puts each value into its slot, escaped (text as text; attributes only from a closed list);
- adds a small resume block: the view token, the version, the CSRF token, and whatever no slot shows. A text already in a slot is never repeated there.
The server runs no component and computes no layout. The page is complete when the HTML arrives. It is private: Cache-Control: no-store, Vary: Cookie. (A static public view is the exception: it holds no user data, so it is the same page for everyone.)
Resume, not hydration
In the browser, the runtime (one shared, hashed file) finds the slots by index, reads back the state they show, and listens for clicks and input by delegation. It creates no node for the static parts and re-renders nothing. If you click before it is ready, the action is queued, not lost.
Without JavaScript, the page still reads complete. Actions need the runtime.
Compare with hydration: React re-runs your components in the browser to rebuild a virtual tree that matches the server's HTML, then attaches handlers. That needs your component code in the browser. In Luxel there is no component code in the browser to re-run.
Updates are deltas
When an event succeeds, the server answers with the changes your handler returned, translated to slot indices. The runtime writes only those slots. Messages travel as compiled templates (an index plus arguments), not as phrases.
The server is the only authority
Every value the page shows comes from the server: totals, page counts, search results, chart scales, formatted money and dates, the labels of buttons that change with state, which actions are available.
The browser:
- shows what the server filled;
- writes what you type into inputs;
- sends events with those inputs;
- applies the declared local transitions (onSuccess: { clear, focus }, a busy label).
It decides nothing about the business and computes nothing. The shipped DOM runtime modules contain no arithmetic operator; a conformance test checks it.
What it costs
Not computing in the browser has a price, and you should know it before you choose Luxel:
- Every recalculation is a round trip. A line total in an order form is recalculated when you leave the field, by the server. On a 4G profile that was about 165 ms per recalculation in the project's measurements. There is no instant client-side total.
- Every page change, search and sort is an event (a POST with its security context: CSRF token, view token, event id), not a GET with a query string.
- Data that changes on the server is polled, not pushed (see Polling).
In exchange, the browser holds no business rule to bypass, and no app code to download or audit.
ASEF = 0
ASEF counts the app-specific executable bytes that reach the browser. In Luxel it is zero: the runtime modules are universal files, and each has the same hash in every app. luxel check fails the build (LUXEL-E031) if anything app-specific and executable would be published: a .js or .wasm asset, the .luxel/ outputs, or a runtime module that is not the shipped universal file.
ASEF = 0 does not mean the page is safe from whoever controls the browser. See Security.
Runtime modules
The runtime is a set of universal modules: the core (resume, transport, DOM renderer) and optional ones such as collection, forms, poll or styles. A page downloads only the modules its manifest declares. The Content-Security-Policy lists the hashes of exactly those modules.
View ids
A view lives in src/views/‹id>.view.tsx. The file name is the view id: contacts.view.tsx is the view contacts. The id is used:
- in the URL: /‹variant>/‹id>, for example /dom/contacts, unless the view declares a path (see Routes);
- as the key of the contract (server/contract.ts) and of views in luxel.config.ts;
- in the generated handler types, in camelCase: views.contacts, views.secureTransfer for secure-transfer.
A view built in another language gets the id ‹id>-‹lang>, for example cobranza-en (see Internationalization).
Variants
A variant is a renderer the host serves a view with. A view without a path is served under /‹variant>/‹view> in each of its variants. You declare them in luxel.config.ts:
variants: { dom: { renderer: 'dom', projection: 'slots' }, },
projection: 'slots' means the server fills the compiled template per request. The DOM renderer is the reference. Luxel Visual (a Canvas renderer, renderer: 'visual') exists in the project's lab with hand-written layouts; it is not covered by this guide. A view can be limited to some variants with views.‹id>.variants, for example ['dom'].
Routes
Every address of an app is known when it is built: that list is its route table. The host answers a page only at an address of the table; any other address is a 404.
A view gets a clean address by declaring a path. In a screen file it is part of route; for a view file or a composite page it goes in luxel.config.ts:
// src/screens/getting-started.screen.tsx export default s.define({ route: { path: '/docs/getting-started' }, … });
// luxel.config.ts views: { about: { public: true, static: true, path: '/company/about' } },
- A path is static. It is /, or one to eight segments of lowercase letters, digits and dashes: /pricing, /docs/getting-started. No trailing slash, no upper case, no dot, no encoded character. A parameter segment (/contacts/:id, *, [id]) does not build: route parameters are not available yet (LUXEL-E064).
- A view without a path keeps its id address, /‹variant>/‹view id>. An app that declares no path has exactly those addresses.
- One view, one address. When a view has a path, its id address answers with a redirect to the path. That is where ctx.navigate('view') and the redirect to loginView end up, so handlers keep naming views by id.
- A path belongs to one variant. A view with a path is served in exactly one variant. In an app with several variants, write variants: ['dom'] next to the path; the build tells you (LUXEL-E064).
- Paths cannot collide. Two views with the same path do not build (LUXEL-E065, with the place of both declarations). A path cannot start with /_luxel, with a variant id (/dom/… is where id addresses live), or be /healthz or /favicon.ico. Two paths cannot differ only by case or by a trailing slash, because neither spelling is a valid path.
- / is the view that declares the path /. If none does, / redirects to home, which must be an address of the table. home is optional when a view declares /.
How the host reads a request's address:
| The request's path | Answer |
|---|---|
| Exactly an address of the table | The page (after sign-in and the view's load policy, as always) |
| The id address of a view that has a path | 302 to the path |
| An address of the table followed by one / | 308 to the address |
| Anything else: another case, %2F, .., //, .html, a prefix of a path | 404 |
Nothing is decoded, lowercased or collapsed before the comparison, so a page is never reachable under a second spelling. A redirect's Location is always an address of the table; no part of the request is copied into it. The query string is not part of the path: a page ignores it.
luxel build writes the declared paths to luxel.config.json (routes). luxel check and luxel-host compute the same table from it with the same code, so a build whose routes were edited afterwards is refused by both.
The table is fixed at build, whatever machine builds it: luxel.config.ts, the contract and the views cannot read process.env, the clock or the network while they are evaluated (LUXEL-E054, LUXEL-E026, LUXEL-E052), because what they declare is compiled into public files. A path is a literal you write, and it is public: never put anything secret in one.
There is no luxel export yet. If you save a site's static pages as files (‹address>/index.html), give a path to every view that is linked: a link to a view with a path is an absolute address and works from /x and from /x/, while a link between two views without a path is relative to the id address and breaks when a static host adds the trailing slash.