This guide walks you through every essential dragonJSON operation using the bundled demo server. By the end you will have a running client that reads lazily-loaded nested data from the server, writes back mutations, and listens for live change events — all with no package manager or build step required.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/michael-tiger-2010/dragonjson/llms.txt
Use this file to discover all available pages before exploring further.
Import dragonJSON
dragonJSON ships as a single ES module file with no external dependencies. Import it directly into your script:
Start the Node.js demo server
The repository includes a zero-dependency reference server built on Node.js built-ins. Start it with:The server starts on port 3000 by default. No
npm install is needed — it relies only on the built-in http and url modules.Initialize the client
Call
dragonJSON with your server’s base URL and any options. The function returns a two-element array: the server proxy you read and write through, and a control object for runtime configuration.| Option | Type | Description |
|---|---|---|
auth | string | Sent as the Authorization header on every request. |
enableBatching | boolean | Coalesces rapid concurrent requests into one round trip. Defaults to true. |
debug | boolean | Logs internal proxy activity to the console. |
liveInvalidation | object | Relay hooks for real-time cross-client sync. See Live Sync. |
Read data
Accessing any property on To pre-warm multiple paths in parallel, pass them to
server builds a path. Awaiting it triggers a fetch for only that path. Once a parent is fetched, its children are cached and resolve instantly.Promise.all:Write data
Use To delete a path, use
$set to update an existing value and $add to append a new entry. Both POST to the server and automatically invalidate the affected cache paths on success.$remove:Listen for changes
Subscribe to mutations at any path with The four event types are
$on. The callback receives an event object containing the affected key, the originating path, and a lazy proxy to the new data."add", "remove", "set", and "*" (any). Pass "*" as the key to match any child. To stop listening, call $off with the same four arguments:The demo server uses an in-memory store. Restart it to reset all data to its initial state.