whatisgithub

What is lokijs?

techfort/lokijs — explained in plain English

Analysis updated 2026-06-24

6,838JavaScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

LokiJS is a fast in-memory document database for JavaScript that stores objects in memory for instant queries, runs in browsers and Node.js without a server, and saves to disk only when you choose.

Mindmap

mindmap
  root((LokiJS))
    Core Features
      In-memory storage
      Document model
      Binary indexes
    Environments
      Browser
      Node.js
      NativeScript
    Advanced Features
      Dynamic views
      Changes API
      Custom persistence
    Use Cases
      Session stores
      Mobile apps
      Desktop web apps
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Store and query user session data in a browser app without making API calls by keeping it in a LokiJS collection

USE CASE 2

Build a high-speed search feature in a Node.js app using binary indexes capable of 500K operations per second

USE CASE 3

Add a local data cache to a mobile app built with NativeScript or Cordova that persists through the session

USE CASE 4

Track live data changes in a dashboard using dynamic views that update automatically as records are added or modified

What is it built with?

JavaScriptNode.js

How does it compare?

techfort/lokijsreach/routeroctref/polacode
Stars6,8386,8416,843
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
Use, modify, and distribute freely including in commercial projects.

So what is it?

LokiJS is an in-memory database written in JavaScript that stores data as documents rather than in rows and tables. You give it JavaScript objects and it saves them in memory, letting you query and retrieve them quickly without setting up a separate database server. It runs in web browsers, in Node.js, and in mobile app frameworks like NativeScript and Cordova/PhoneGap. The library is designed for situations where speed matters more than permanent storage, or where you want to keep data in memory during a session and save it elsewhere when done. Common use cases listed in the README include session stores, performance-critical apps, mobile apps that need to avoid calling native device databases, and desktop apps built with web technologies. It achieves fast query speeds by maintaining indexes on the data: a unique index handles about 1.1 million operations per second, and a binary index about 500,000. Features include dynamic views, which are live subsets of a collection that update automatically as data changes, a built-in persistence layer with support for custom adapters so you can write data out to disk or another store when needed, a changes API for tracking modifications, and basic join operations between collections. Installation is through npm for Node.js environments or by including a single JavaScript file in the browser. A sandbox playground was available for trying it out without any setup. The project is MIT licensed and was at version 1.3 at the time the README was last updated. Commercial support and a planned roadmap toward MongoDB API compatibility and horizontal scaling are also mentioned.

Copy-paste prompts

Prompt 1
Show me how to create a LokiJS collection in Node.js, insert 100 JavaScript objects, and query them by a specific field value.
Prompt 2
Set up LokiJS with a file persistence adapter so the database automatically saves to disk every 5 seconds in Node.js.
Prompt 3
Using LokiJS dynamic views, create a view that always shows only records where status equals active and updates automatically as data changes.
Prompt 4
Help me build a simple in-memory session store using LokiJS in a browser app that keeps user preferences during the page session.

Frequently asked questions

What is lokijs?

LokiJS is a fast in-memory document database for JavaScript that stores objects in memory for instant queries, runs in browsers and Node.js without a server, and saves to disk only when you choose.

What language is lokijs written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js.

What license does lokijs use?

Use, modify, and distribute freely including in commercial projects.

How hard is lokijs to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is lokijs for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.