Memory
Use storage: 'memory' for demos, temporary sessions, and test fixtures.
These sample records load through an asynchronous in-memory adapter. Search and filter the loaded history; no backend is contacted.
Memory
Use storage: 'memory' for demos, temporary sessions, and test fixtures.
Local Storage
Use storage: 'localStorage' when browser persistence is enough for the workflow.
Custom Adapter
Use storage: 'custom' with storageAdapter when your backend should load, append, save, or clear records.
Provider Chain
Use storageProviders to list cache or server providers. Provider loads refresh the panel automatically.
Record Limit
Use maxRecords to bound retained records. The implementation defaults to 1000.
For production systems, prefer a trusted server provider. If you include several providers, the default is intentionally isolated: the first provider that returns records owns the loaded audit trail, and later providers with records are ignored with a console warning. Set mergeStorageProviders: true only when your app deliberately wants to merge records by id across providers.
const auditHistory: AuditHistoryConfig = { getCurrentUser: () => currentUser, rowIdProp: 'id', storageProviders: [ { async load() { const response = await fetch('/api/audit-history'); return response.json(); }, async append(record) { await fetch('/api/audit-history', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(record), }); }, async save(records) { await fetch('/api/audit-history', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(records), }); }, async clear() { await fetch('/api/audit-history', { method: 'DELETE' }); }, }, ],};Provider write failures emit auditerror but do not block editing. Configuring storageProviders together with storage or storageAdapter shows a console warning because storageProviders takes precedence.
When you need a deliberate cache-plus-server merge, opt in explicitly:
const auditHistory: AuditHistoryConfig = { rowIdProp: 'id', mergeStorageProviders: true, storageProviders: [ createLocalStorageAuditHistoryAdapter('invoices:audit-history'), serverAuditHistoryAdapter, ],};Provider chains are useful when the user should see cached history quickly while a server-backed provider loads the durable records.
The panel mounts and reads the current in-memory records.
Storage providers load in order. By default, the first provider that returns records owns the loaded audit trail.
The plugin emits auditrecordsloaded whenever loaded records are applied.
The built-in panel refreshes on auditrecordsloaded, auditrecord, and auditrestore, so async loads and external restore controls stay visible without polling.
Use refreshRecords when your custom storage adapter can load existing records from a backend. A single storageAdapter still supports merge-by-id refreshes by default; pass { merge: false } to replace the local set. Provider chains follow the configured provider policy: isolated by default, merged only with mergeStorageProviders: true.
await auditHistoryPlugin?.refreshRecords();await auditHistoryPlugin?.replaceRecords(serverRecords, { merge: false });Apply privacy and policy controls before persisting sensitive changes.