
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
tanstack-filesystem-collection
Advanced tools
A filesystem-based collection adapter for TanStack DB. Stores your data as JSON or CSV files on disk.
⚠️ Heads up: This is a proof-of-concept. The sync engine is a bit flaky and definitely not production-ready. Great for testing, CLI tools, and local dev though.
TanStack DB is runtime-agnostic, so why not use the filesystem as a backend? This lets you:
Note: This only works in Node.js and Bun. No browser support (obviously), and Deno isn't planned.
npm install tanstack-filesystem-collection @tanstack/db
# or
bun add tanstack-filesystem-collection @tanstack/db
import { createCollection } from "@tanstack/db"
import { filesystemCollectionOptions } from "tanstack-filesystem-collection"
import { z } from "zod"
const todoSchema = z.object({
id: z.string(),
text: z.string(),
done: z.boolean(),
})
const todos = createCollection(
filesystemCollectionOptions({
id: "todos",
schema: todoSchema,
getKey: (item) => item.id,
})
)
This creates a todos.json file in .tanstack-collection-cache/ and keeps it in sync with your collection.
| Option | Default | What it does |
|---|---|---|
id | required | Collection name (also the filename) |
getKey | required | Function to get unique key from an item |
schema | - | Zod/Standard Schema for validation & types |
format | "json" | "json" or "csv" |
cacheDir | ".tanstack-collection-cache" | Where to store files |
rowUpdateMode | "partial" | "partial" merges changes, "full" replaces |
runtime | auto-detected | Force "bun" or "node" |
codec | - | Transform data on read/write |
enableFileWatch | false | Watch file for external changes |
fileWatchDebounce | 100 | Debounce ms for file watching |
You can hook into mutations for backend sync:
| Option | Default | What it does |
|---|---|---|
onInsert | - | Called after filesystem write on insert |
onUpdate | - | Called after filesystem write on update |
onDelete | - | Called after filesystem write on delete |
awaitPersistence | false | Wait for handlers to complete |
persistenceTimeoutMs | 5000 | Timeout for handlers |
swallowPersistenceErrors | true | Log errors instead of throwing |
const logs = createCollection(
filesystemCollectionOptions({
id: "logs",
format: "csv",
getKey: (item) => item.timestamp,
})
)
const config = createCollection(
filesystemCollectionOptions({
id: "config",
cacheDir: "./data",
getKey: (item) => item.key,
})
)
const events = createCollection(
filesystemCollectionOptions({
id: "events",
getKey: (item) => item.id,
codec: {
parse: (raw) => ({ ...raw, date: new Date(raw.date) }),
serialize: (item) => ({ ...item, date: item.date.toISOString() }),
},
})
)
The collection exposes some handy utils via collection.utils:
// Get the file path
todos.utils.getFilePath() // ".tanstack-collection-cache/todos.json"
// Clear the cache file
await todos.utils.clearCache()
// Local operations (bypass user handlers)
await todos.utils.insertLocally(item)
await todos.utils.updateLocally(id, item)
await todos.utils.deleteLocally(id)
// Bulk operations
await todos.utils.bulkInsertLocally(items)
await todos.utils.bulkUpdateLocally(items)
await todos.utils.bulkDeleteLocally(ids)
Works great with @tanstack/react-db in custom React renderers like OpenTUI:
import { useLiveQuery } from "@tanstack/react-db"
function TodoList() {
const { data: todos } = useLiveQuery(todosCollection)
return (
<box>
{todos.map(todo => (
<text key={todo.id}>{todo.text}</text>
))}
</box>
)
}
MIT
FAQs
Filesystem collection adapter for TanStack DB
We found that tanstack-filesystem-collection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.