NukeBase Documentation
NukeBase documentation — the real-time database with server-side triggers, callables, security rules, built-in authentication, and a WebSocket client SDK.
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 and remove — auto-creation, durable writes, and the server-side data export.
Query Operations
Search NukeBase collections with query() — the safe expression engine, operators, childPath for nested data, and numeric childPath array handling.
Security Rules
Control database access with NukeBase read, write and validate rules — path patterns, wildcards, cascading evaluation, and array validation.
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 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, 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.