JavaScript / TypeScript SDK
Complete guide to the Logstack JavaScript/TypeScript SDK (logstack-js).
JavaScript / TypeScript SDK
The logstack-js package for Node.js, browsers, Deno, Bun, and edge runtimes.
| npm | logstack-js |
| Import | import { createLogStack } from "logstack-js" |
| Default API | https://api.logstack.tech |
| Ingest path | POST {endpoint}/v1/logs |
Installation
Quick start
Features
- Automatic batching — buffer + flush interval
- Retry with backoff — failed requests retried
captureConsole(default on) — shipsconsole.*withsource: "console"- Offline queue — browser localStorage cap (
maxOfflineQueueSize) - TypeScript — full type definitions
- Graceful shutdown —
flush()/close()
Log levels
| Level | Method | Use case |
|---|---|---|
debug | logstack.debug() | Verbose diagnostics |
info | logstack.info() | Normal operations |
warn | logstack.warn() | Potential issues |
error | logstack.error() | Failures |
critical | logstack.critical() | Immediate attention |
fatal | logstack.fatal() | Process-ending errors |
API reference
createLogStack(options)
Logging methods
Flush and close
Always call close() on graceful shutdown so buffered logs are not lost.