---
title: "Node.js"
description: "Filesystem durability on Node.js 18+ with a destination adapter you supply."
---

> Documentation Index
> Fetch the complete documentation index at: https://logbun-docs.abshahin.workers.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js

The root package has no `node:` imports. On Node, import filesystem reliability from the subpath and supply a destination (`TursoAdapter`, `ClickHouseAdapter`, or a custom `IAdapter`). `BunSQLiteAdapter` will not load — it imports `bun:sqlite`.

```ts title="audit.ts"
import { AuditLogger, ENTERPRISE_DEFAULTS, type IAdapter } from 'logbun';
import { FileReliabilityAdapter } from 'logbun/durability/filesystem';

declare const destination: IAdapter;

const instanceId = process.env.INSTANCE_ID ?? 'my-app-instance-1';

const audit = new AuditLogger({
  ...ENTERPRISE_DEFAULTS,
  namespace: 'my-app',
  reliability: new FileReliabilityAdapter({
namespace: instanceId,
dataDir: '.logbun',
wal: { fsync: true },
dlq: { fsync: true },
encryptionKey: process.env.LOGBUN_ENCRYPTION_KEY,
  }),
  adapter: destination,
  redactPaths: ['password', 'token'],
  retention: { days: 90 },
});

await audit.ready;
await audit.fireAsync('user.created', {
  tenantId: 't1',
  actorId: 'u1',
});
```

Schedule `runMaintenance()` from cron or a supervisor. The filesystem adapter does not wake the process on its own.

`encryptionKey` accepts 32 raw bytes, 64-character hex, or base64 of 32 bytes. Passphrases are rejected (no silent SHA-256). See [Production](/guides/production).

CJS `require('logbun')` and `require('logbun/durability/filesystem')` are supported. `logbun/durability/cloudflare` is ESM-only.

Source: https://logbun-docs.abshahin.workers.dev/guides/node/index.mdx
