EdgeLiteDB
documentation.
Everything you need to build adaptive, edge-first UIs. Start with the quick start, dive into the API reference, or jump straight to a guide.
Installation
EdgeLiteDB ships from https://edgelitedb.io/v1/ as native ES modules. No build step required — import directly in the browser or any modern runtime.
CDN (zero install)
npm / pnpm / bun
EdgeLiteDB targets ES2020+. For legacy browser support, run the output through your existing transpile pipeline — EdgeLiteDB itself ships untranspiled ESM.
Quick start
Define a component with edge(), create reactive state with sync(), mount it, and subscribe to re-render on changes.
Core concepts
Templates
Templates are standard JavaScript template literal strings. Every prop in the props array is available as a bare variable inside the template. EdgeLiteDB compiles them to a cached render function at component definition time — not on every render.
Adaptive layer
The adaptive option accepts any adapt.* rule or a composed set of rules. At render time, the adaptive layer reads the current ENV snapshot and injects additional props into the template. No manual device detection needed.
Signal mesh
EdgeLiteDB silently collects anonymous UI error signals (tap misfires, scroll jank, layout shift) and forwards them to the edge aggregator. These signals inform future adaptive rule updates. All signals are hashed and stripped of PII at the device before transmission.
edge( definition ) → Component
The primary factory for creating EdgeLiteDB components.
| Option | Type | Required | Description |
|---|---|---|---|
| template | string | Yes | Template literal string. Props are injected as bare variables. |
| props | string[] | No | Documented prop names. Used for type hints and devtools. |
| adaptive | AdaptRule | No | An adapt.* rule or adapt.compose(...rules). Runs before every render. |
| hooks | object | No | Lifecycle hooks: beforeRender, afterRender, mounted, updated. |
| styles | string | No | CSS string injected once into document head. Scoped by a generated ID. |
The returned Component has three methods: .render(props) returns an HTML string, .mount(selector, props) writes into the DOM, .update(selector, props) diffs and re-writes only when output changes.
adapt.*
All adapt helpers return an object with a .resolve(meta, env) method that merges additional props into the component at render time.
adapt.tapTarget( options )
Injects _tapMin on touch devices. Use it in templates to conditionally apply minimum touch target sizing.
minSize— minimum pixel size (default: 44)signal— signal name to watch (default: 'misfire-rate')
adapt.compact( options )
Injects compact: true when the viewport is narrower than breakpoint (default: 480px).
adapt.retina( options )
Injects _retinaMode: true and _suffix when devicePixelRatio >= 2. Use to swap in @2x images.
adapt.compose( ...rules )
Merges multiple adapt rules into one. Rules are applied left-to-right; later rules can override earlier ones.
sync( initialState ) → Store
A minimal reactive state container. Designed to be used alongside edge() for fully reactive component trees.
| Method | Description |
|---|---|
| .get(key?) | Read one key or the entire state object. |
| .set(key, value) | Update a single key, notifies all subscribers. |
| .patch(partial) | Shallow-merge a partial object into state. |
| .subscribe(fn) | Called with the full state after every update. Returns unsubscribe fn. |
| .reset() | Restore initial state and notify subscribers. |
router( routes ) → Router
Hash/history API router. Route keys are path strings supporting :param segments. A * key acts as a catch-all.
ENV
A read-only object resolved at import time. Useful for any manual device branching outside of the adaptive layer.
| Property | Type | Values |
|---|---|---|
| ENV.platform | string | 'browser' | 'node' | 'deno' | 'bun' | 'edge' |
| ENV.device | string | 'mobile' | 'tablet' | 'desktop' |
| ENV.touch | boolean | true if ontouchstart is available |
| ENV.dpr | number | devicePixelRatio (1, 1.5, 2, 3…) |
| ENV.ua | string | Full user agent string |
Telemetry & privacy
EdgeLiteDB's adaptive engine learns from anonymous device signals. Here's exactly what is and isn't collected:
- Tap misfire rate (did the user hit the target?)
- Scroll jank events (frame drops during scroll)
- Layout shift score (CLS events)
- Device class and DPR (mobile/tablet/desktop, not fingerprinted)
No URLs, no user identifiers, no session data, and no content is ever transmitted. To opt out entirely: