Store and search Mem0 memories from a TypeScript or JavaScript app in minutes.
Spin up Mem0 with the Node SDK in just a few steps. You’ll install the package, initialize the client, add a memory, and confirm retrieval with a single search.
import { Memory } from "mem0ai/oss";const memory = new Memory();
3
Add a memory
Copy
Ask AI
const messages = [ { role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" }, { role: "assistant", content: "How about thriller movies? They can be quite engaging." }, { role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." }, { role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." }];await memory.add(messages, { userId: "alice", metadata: { category: "movie_recommendations" } });
4
Search memories
Copy
Ask AI
const results = await memory.search("What do you know about me?", { userId: "alice" });console.log(results);
Output
Copy
Ask AI
{ "results": [ { "id": "892db2ae-06d9-49e5-8b3e-585ef9b85b8e", "memory": "User is planning to watch a movie tonight.", "score": 0.38920719231944799, "metadata": { "category": "movie_recommendations" }, "userId": "alice" } ]}
By default the Node SDK uses local-friendly settings (OpenAI gpt-4.1-nano-2025-04-14, text-embedding-3-small, in-memory vector store, and SQLite history). Swap components by passing a config as shown below.
create table memory_history ( id text primary key, memory_id text not null, previous_value text, new_value text, action text not null, created_at timestamp with time zone default timezone('utc', now()), updated_at timestamp with time zone, is_deleted integer default 0);