MCPcopy Index your code
hub / github.com/TanStack/db / createInMemoryStorage

Function createInMemoryStorage

packages/db/src/local-storage.ts:198–212  ·  view source on GitHub ↗

* Creates an in-memory storage implementation that mimics the StorageApi interface * Used as a fallback when localStorage is not available (e.g., server-side rendering) * @returns An object implementing the StorageApi interface using an in-memory Map

()

Source from the content-addressed store, hash-verified

196 * @returns An object implementing the StorageApi interface using an in-memory Map
197 */
198function createInMemoryStorage(): StorageApi {
199 const storage = new Map<string, string>()
200
201 return {
202 getItem(key: string): string | null {
203 return storage.get(key) ?? null
204 },
205 setItem(key: string, value: string): void {
206 storage.set(key, value)
207 },
208 removeItem(key: string): void {
209 storage.delete(key)
210 },
211 }
212}
213
214/**
215 * Creates a no-op storage event API for environments without window (e.g., server-side)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected