Run it on a SQLite file
memento runs on PostgreSQL or on a single SQLite file. On SQLite the server needs Node 24 and a
local disk, nothing else: no Docker, no database service, no Redis. The driver is Node’s
built-in node:sqlite, and the memento command line opens the same file directly.
-
Make a directory and install the server and the command line (Node 24 or newer,
curlandjq):Terminal window mkdir my-memento && cd my-mementonpm install @jsmemento/server @jsmemento/cli -
Point memento at a database file. A relative
file:path is relative to the working directory;file:///var/lib/memento/memento.dbis an absolute one. LeaveREDIS_URLunset:Terminal window export DATABASE_URL=file:data/memento.db # the database, one file; no REDIS_URLexport PORT=9300 # the default is 8000 -
Create the database. The server would also migrate at start;
memento migratecreates the file and its directory now:Terminal window npx memento migratels dataWhat it printed migrations appliedmemento.db -
Make a tenant and an API key of it. No server has to be running, because each command opens the file. The
mk_…secret is printed once; only a hash of it is stored:Terminal window npx memento create-tenant acme --name "Acme Inc"npx memento create-key --tenant acme --scopes read,write --name backendWhat it printed created tenant acme (Acme Inc) id=01a1e1f1-7334-7cae-962d-0771cf7ccc9acreated key "backend" for acme [read,write]prefix: azvue4n7key: mk_azvue4n7_…Store it now: it cannot be shown again. -
Start the server. Its log is JSON on stdout, with no Redis line and no PostgreSQL line. The warnings about
lookups.yamlandmenu.yamlare expected for an npm install: both files are optional, the image bundles them, and events still render from the templates in the package.Terminal window node node_modules/@jsmemento/server/dist/server.jsWhat it printed {"level":30,…,"database":"SQLite …/my-memento/data/memento.db","msg":"database migrated and open"}{"level":30,…,"path":"…/my-memento/node_modules/lookups.yaml","sections":[],"strict":false,"msg":"lookups loaded"}{"level":40,…,"msg":"…/my-memento/node_modules/lookups.yaml not found: lookups disabled"}{"level":40,…,"msg":"…/my-memento/node_modules/menu.yaml not found: no menu UDC collection"}{"level":30,…,"msg":"Server listening at http://127.0.0.1:9300"} -
In a second terminal, in the same directory, push the first event and read the history of
user/42back, rendered in Serbian:Terminal window export KEY=mk_… # what create-key printedcurl -s localhost:9300/memento/api/health; echocurl -s -X POST localhost:9300/memento/events -H "Authorization: Bearer $KEY" \-H 'content-type: application/json' \-d '{"event_type":"USER_LOGIN","instance_type":"user","instance_id":42,"actor_id":"igor"}' \| jq '.data | {event_type, instance_type, instance_id, rendered}'curl -s "localhost:9300/memento/entities/user/42/events?locale=sr" -H "Authorization: Bearer $KEY" \| jq -c '[.data[] | {event_type, actor_id, rendered}]'ls dataWhat it printed {"ok":true,"data":{"status":"ok"}}{"event_type": "USER_LOGIN","instance_type": "user","instance_id": "42","rendered": "User igor logged in."}[{"event_type":"USER_LOGIN","actor_id":"igor","rendered":"Korisnik igor se prijavio."}]memento.dbmemento.db-shmmemento.db-walmemento.db-walandmemento.db-shmare part of the database while the server has it open. Stop the server withCtrl-C: it closes the file cleanly, and onlymemento.dbremains.
What SQLite gives up
Section titled “What SQLite gives up”Events, the Filter DSL, entity history, templates, chats, tenants and keys, the UDC collections
and the /ws stream answer the same as on PostgreSQL. What changes is how far it scales:
- One server process on the file, on one host. Your own application counts as that process
when it embeds the plugin.
mementoCLI commands next to it are fine. For more than one server, use PostgreSQL. - No Redis needed. The process streams what it stores to its own
/wsclients, and keeps the rate limits and quota counts itself.REDIS_URLis accepted, but it does not allow a second server process. - The examples site or the service site, one per process, not both side by side.
- The file on a local disk. Never on NFS or SMB, and never opened from two hosts.
Deployment modes has the features by
database, and the SQLite guide has the rest: the image and Compose on one
file, accounts and the service site, retention from cron, backups with VACUUM INTO, restores,
upgrades and what not to do with the file.
- Push from your own code: the client programs work against this server
with
MEMENTO_URL=http://localhost:9300/memento. - Every route, with its answers and error codes: HTTP API.
- Every variable the server reads,
DATABASE_URLfirst: Environment variables.
v1.1.0released built 663143e