Skip to main content

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.

dragonJSON(url, options) is the single entry point for the dragonJSON client. It returns a two-element array [server, control]. The server proxy is how you read and mutate data; control provides runtime configuration and debugging utilities.

Signature

import dragonJSON from './client/web-client.js';

const [server, control] = dragonJSON(url, options);

Parameters

url
string
required
The base URL of your dragonJSON-compatible server. All requests are made relative to this URL.
options
object
Configuration object controlling batching, auth, debugging, and live sync behavior.

Return Value

dragonJSON returns a two-element array: [server, control].
server
Proxy
The root proxy. Every property access chains a path segment; await triggers a fetch and cache lookup. Use $ methods on this proxy to mutate data. See Reading Data and Mutations.
control
object
Runtime control object with the following members:

Example

import dragonJSON from './client/web-client.js';

const [server, control] = dragonJSON("https://api.example.com/data", {
  auth: "Bearer my-token",
  enableBatching: true,
  debug: false,
  liveInvalidation: {
    sendRelayMessage: (msg) => socket.emit("invalidate", msg),
    onReceiveCallback: (cb) => socket.on("invalidate", cb),
  },
});

// Update options at runtime
control.setOptions({ debug: true });

Constraints

  • Property names in paths must not contain "."
  • Property names cannot be "then" or "exists"
  • Property names cannot start with "$"
  • Your server must return { invalidate: [...] } from all mutation endpoints

Build docs developers (and LLMs) love