Reference Entry
Portable JSON Index State
Indexing · indexing · order 20
Serialize index structures and hydrate them again without reindexing.
Relevant APIs
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:
- Build your
DocumentIndexorcreateSimpleTextSearchIndex(...)bundle during your site build. - Serialize the resulting index state to JSON.
- Fetch that JSON in the browser.
- Hydrate the index state.
- Run search queries locally in the browser.
That pattern keeps your runtime simple and gives users a responsive search box without a search server.