NukeBase Documentation
NukeBase documentation — the real-time database with server-side triggers, callables, security rules, built-in authentication, and a WebSocket client SDK.
Prefer everything on one page? Read the docs as a single page →
Server-Side API
Server Setup
Provision a NukeBase project, set up local development, and configure server/app.js with the core API exports.
Starting the Database
Start the NukeBase server with startDB() and addDomain — host, port, authPath, and the environment variables the server reads.
Serving Static Files
Serve frontend files and assets with app.serveStatic, including auth callbacks, path-traversal protection, and caching behavior.
CRUD Operations
Create, read, update and delete data in NukeBase with set, get, update, increment and remove — auto-creation, atomic counters, durable writes, and the server-side data export.
Query Operations
Search NukeBase collections with query() — the safe expression engine, orderBy sorting, limit and cursor pagination, count, indexes, and childPath for nested data.
Query Authorization
How a NukeBase query is authorized — one collection-level read check, why read rules do not filter results, and why an ownership rule denies queries outright.
Sorting & Pagination
Order and page query results with orderBy, desc, limit, startAt, cursor and count — mixed-type ordering, nextCursor paging, and the response metadata.
Query Indexes
Declare query indexes in rules.js and read the planner — index-order, index-filter, index-union and index-count, plus the automatic key index.
Query childPath
Query and return only a nested portion of each record with childPath — response shape, numeric segments and arrays, and what it is not for.
File Storage
Store and serve files with getFile, setFile, listFiles and removeFile — fileRead/fileWrite/fileValidate rules, file triggers, and the /_file/ HTTP routes.
File Client API
Upload, download, list and delete from the browser with setFile, getFile, listFiles and removeFile — progress reporting, AbortSignal cancellation, and structured errors.
File Server API
The async server-side file operations — getFile, setFile, listFiles, removeFile, fileStat and fileUrlFor — and why they run as root unless you pass a caller.
File Rules
Govern the file store with fileRead, fileWrite and fileValidate — the file descriptor, content sniffing, and why an upload is validated twice.
File Triggers
addFileTrigger's four points — reserve, release, write and remove — the context object, and why reserve is a gate rather than a notification.
File Quotas
A per-user storage quota built from file triggers and increment — booking the delta so an overwrite isn't charged twice, and the rule that spends the ledger.
File Limits
Path resolution as the security boundary, atomic uploads, and the size, listing and upload-rate caps with the environment variables that set them.
Security Rules
Control database and file access with NukeBase read, write, validate and fileRead/fileWrite/fileValidate rules — path patterns, wildcards, cascading evaluation, and index declarations.
Auth Context
The admin auth context object available in NukeBase security rules, callables, connection triggers, and POST handlers.
Database Triggers
Run server code in response to database changes with addDbTrigger — event types, path wildcards, and the context object.
Callable Functions
Define server-side functions clients invoke over WebSocket with addCallable — the data, admin and sessionId arguments, and sync or async return values.
Connection Triggers
Run server code when a client connects or disconnects using addConnectionTrigger with open and close handlers, the admin auth context, and the session ID.
Custom POST Endpoints
Define POST routes in NukeBase with postWithBody and raw post handlers — body parsing, file uploads, and authentication.
External Databases
Connect your server to another NukeBase instance with serversdk.js for microservices and server-to-server sync.
Storage & Backups
How NukeBase stores data and files on disk — the $split tree, atomic writes, crash safety, and automatic daily backups.
Complete Server Example
A minimal but complete NukeBase server setup with domain config, static files, triggers, callables, and connection tracking.
Client-Side API
Client-Side API
The NukeBase client library — a real-time WebSocket connection with automatic reconnection and subscription restoration.
Connection Setup
Connect to NukeBase from the browser with createClient() — full client, destructured methods, or global window patterns.
Real-time Subscriptions
Live data with getSub, querySub, getSubChanged and querySubChanged — childPath, windowed subscriptions, operation prefixes, and bubble-up behavior.
Calling Callables
Invoke server-side callables from the browser with callableFunction(name, data) over the existing WebSocket connection for the lowest possible latency.
Authentication
Built-in cookie-based auth in NukeBase — login, createuser, logout, change password, magic links, and custom claims.
Response Format
Every NukeBase operation returns a standardized response object with action, data, requestId and status fields. Learn the success and error response shapes.
Complete Client Example
A complete client-side NukeBase example using createClient() — data operations, queries, callables, and subscriptions.