Querylight TS Demo

Portable JSON Index State

Serialize index structures and hydrate them again without reindexing.

Back to docs search

Reference Entry

Portable JSON Index State

Indexing · indexing · order 20

Serialize index structures and hydrate them again without reindexing.

Portable JSON Index State

Querylight index state is intentionally JSON-serializable.

Serialize

const state = JSON.parse(JSON.stringify(index.indexState));

Hydrate

const hydrated = index.loadState(state);

Why it is useful

  • Precompute indexes at build time
  • Ship them to the browser
  • Avoid reindexing on startup
  • Keep test fixtures deterministic

This is the recommended architecture for documentation and static-site search:

  1. Build your DocumentIndex or createSimpleTextSearchIndex(...) bundle during your site build.
  2. Serialize the resulting index state to JSON.
  3. Fetch that JSON in the browser.
  4. Hydrate the index state.
  5. Run search queries locally in the browser.

That pattern keeps your runtime simple and gives users a responsive search box without a search server.

Learn more