When I built BlazorMemory, I knew from the start that storing memories in the browser had one obvious problem. What happens when you clear your browser data? Or switch devices? Everything is gone.
v0.3.0 fixes that with two new methods: ExportAsync and ImportAsync.
What it does
Export serialises all memories for a user to JSON:
var json = await memory.ExportAsync(userId);
The output looks like this:
{
"userId": "demo_user",
"exportedAt": "2025-03-15T10:00:00Z",
"version": "1.0",
"memories": [
{
"id": "abc123",
"content": "User is a senior .NET engineer",
"learnedAt": "2025-03-14T09:30:00Z"
}
]
}
Notice embeddings are not in the export. They are large (1,536 floats per memory) and they are model-specific. If you exported with text-embedding-3-small and later imported using a different model, the similarity search would break. So the export skips them, and import re-generates them fresh.
Import reads the JSON, skips any memory whose content already exists (to avoid duplicates), and stores the rest:
await memory.ImportAsync(userId, json);
It is built into the MemoryPanel component
If you use BlazorMemory.Components, you get Export and Import buttons in the panel footer with no extra code:
<MemoryPanel UserId="@userId" IsOpen="true" />
Export triggers a browser file download. Import opens a file picker that accepts .json files.
Both buttons are opt-in via parameters if you want to hide them:
<MemoryPanel UserId="@userId"
AllowExport="false"
AllowImport="false" />
Why not include the embeddings
I thought about this. Including embeddings would make the import faster since you skip the re-embedding API call. But it creates two problems.
First, file size. A user with 50 memories using text-embedding-3-small would have a 300KB export file. Not terrible, but not great either.
Second, model coupling. If you export from an app using OpenAI embeddings and import into an app using a different provider, the vectors are incompatible and similarity search silently breaks. Re-generating on import keeps things clean regardless of which embedding provider the target app uses.
Getting started
dotnet add package BlazorMemory
dotnet add package BlazorMemory.Storage.IndexedDb
dotnet add package BlazorMemory.Embeddings.OpenAi
dotnet add package BlazorMemory.Extractor.OpenAi
dotnet add package BlazorMemory.Components
builder.Services
.AddBlazorMemory()
.UseIndexedDbStorage()
.UseOpenAiEmbeddings(apiKey)
.UseOpenAiExtractor(apiKey);
<MemoryPanel UserId="@userId" IsOpen="true" />
That is all you need. The panel handles display, delete, clear, export, and import.
Top comments (0)