The core chapter of the Neblla guide — the SDK's base contract. Mandatory: every other chapter assumes what is here. # Neblla — core ## What it is **AI builds it in minutes. Neblla keeps it alive for years.** The backend and back office for your game, your app or your store: users, data, payments, real-time multiplayer rooms, community, AI and a dashboard to run it all. **You write the app, Neblla handles everything behind it** — the parts that would otherwise need a server of your own: user accounts that work across every Neblla app, saved data, payments, user-published content, friends, AI, a back office and, when more than one device is involved, rooms with a clear authority. Multiplayer is one of those modules, not a requirement. Loaded with one ` ``` When the page loads, `onNeblla` runs with the SDK already connected. The script tag does NOT need `type="module"`. If the SDK cannot start, `onNeblla` does not run and you are told once: define `window.onNebllaError = (detail) => { ... }` or listen for the `neblla:error` DOM event (same `detail`). `detail.code` is `unreachable` (Neblla could not be contacted), `not_found` (this page is no app's: its origin is not in the app's domains), `refused` (the app lets nobody new in right now: `reason` is `quota_exceeded`, `storage_full`, `migrating`, `rate_limited` when this address opened too many pages in a minute or made too many new guests, or `turnstile_failed` when the app asks for Turnstile and the page did not pass it), `auth_failed` (the server refused the connection, with `status`), `timeout` (no session after 15 s; the SDK keeps retrying and `onNeblla` may still arrive) or `sdk_error`. Use it to paint an "offline — retry" instead of a blank screen. What your code throws and nobody catches reaches your log (the panel: Build › Errors and refusals; your AI: `neblla_get_logs`), with its file and line: an error or a rejected promise on the page (`client.js` and your other files) and what a handler of `lobby.js`, `gathering.js` or `room.js` throws on the room's server peer. It is a sample: at most 10 different errors a minute from each page, and the same one again only adds to its count. Nothing changes for your app: the error still shows in the console as always. Errors of other origins (the browser only says "Script error.") and of browser extensions are not sent. ## The canonical structure — six files If the app is hosted on Neblla, its public link points at `index.html`. The canonical template is six files; only `index.html` is required, and the rest exist if the app needs them. Front end (runs in the browser): - **index.html** — markup. Loads `main.css`, `client.js` and the Neblla SDK. - **main.css** — styles. - **client.js** — runs on every connected device. Has access to the DOM. The code goes inside `window.onNeblla = (neblla) => { ... }`. Server side (isolated logic, no DOM, the `server/` folder): - **server/lobby.js** — users who are not in a game yet. Matchmaking: collecting "I'm ready", grouping players, booking a room, announcing the match. - **server/gathering.js** — a room that exists and is waiting to start. Decides *when* the game begins (the common cases are configured without code in the panel, Features › Rooms). - **server/room.js** — the running room. The room's authority: validates actions, holds state, announces changes. The contract for this structure: - `index.html` references `main.css` and `client.js` with `` and `