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.

Every property access on the server proxy chains a path segment and returns a new proxy. Nothing is fetched until you await the expression. Once a path is fetched, its data is stored in the local cache so that subsequent accesses to the same path or any of its children resolve instantly without a network call.

Awaiting a Path

const value = await server.a.b.c;
Each property access (a, b, c) appends a segment to the internal path array. When you await, dragonJSON calls resolvePath, traversing the cache first. If any segment is missing or marked stale (__next), it issues a fetch for the shallowest uncached segment and populates the cache before returning.
  • If the resolved value is a primitive (string, number, boolean), it is returned directly.
  • If the resolved value is an object, you get back another Proxy rooted at that path — not a plain JavaScript object.
If you await a path whose value is an object, you get back another Proxy — not a plain object. Use Object.keys() on the awaited proxy to enumerate known cache keys.

$prefetch(keys)

Parallel prefetch of sibling keys at the current scope. Signature: $prefetch(keys: string[]) → Promise<any[]>
// Parallel fetch of page1 and page2 under posts
await server.posts.$prefetch(["page1", "page2"]);

// Equivalent with Promise.all
await Promise.all([server.posts.page1, server.posts.page2]);
$prefetch resolves each key in keys relative to the current proxy path, populating the cache for all of them. The return value is an array of resolved values (primitives or Proxies) in the same order as keys.

$exists()

Check if a path exists on the server, fetching it if not already cached. Signature: $exists() → Promise<boolean>
const exists = await server.posts.page3.$exists();
// true if the path resolves, false if it throws or returns undefined
$exists calls resolvePath internally and returns true if it resolves to any value. If the fetch fails or the path resolves to undefined, it returns false — it never throws. This is useful for checking dynamic keys in __more collections where you don’t know which keys exist up front.

$loaded()

Check if a path is already present in the local cache without making any network request. Signature: $loaded() → Promise<boolean>
if (await server.posts.page1.$loaded()) {
  // no network call needed
  const post = await server.posts.page1;
}
$loaded walks the cache along the path. It returns true only if every segment exists in rootData and none of them is a __next placeholder stub. Returns false if any segment is missing or is still unresolved.

$get(command)

Send a freeform query to the server without touching the cache. Signature: $get(command: object) → Promise<any>
// Paginate
const page = await server.posts.$get({ action: "paginate", cursor: 0, limit: 10 });
// { items: {...}, nextCursor: 10, total: 42 }

// Search
const results = await server.posts.$get({ action: "search", query: "hello" });
// [{ key: "page1", title: "Hello World", ... }]
$get appends ?path=<current-path>&command=<JSON> to the base URL and performs a plain GET. The server can return any JSON value. The result is returned directly to your code — it is never stored in the local cache. This is the recommended escape hatch for transient queries such as pagination, full-text search, or any operation that returns data you do not want to cache.

Build docs developers (and LLMs) love