A lightweight TypeScript library that captures browser environment information for bug reports and debugging. Collects OS, browser, screen, network, device, storage, and timezone details β all with zero dependencies and no external requests.
- Browser detection β Name, version, language, and capabilities
- OS information β Operating system and architecture details
- Screen details β Resolution, viewport, color depth, and orientation
- Device info β Touch support, mobile/tablet detection, hardware specs
- Network data β Connection type, speed, and data saver status
- Storage support β LocalStorage, cookies, IndexedDB availability
- Timezone info β User's timezone and locale settings
- Easy sharing β Copy to clipboard or download as file
- Privacy focused β No tracking, no external requests
- Zero dependencies β Lightweight and fast
- TypeScript support β Full type definitions included
- Modern browser with ES2020 support
npm install @watarutmnh/envsnap<script src="https://unpkg.com/@watarutmnh/envsnap@latest/dist/index.js"></script>import EnvSnap from '@watarutmnh/envsnap';
// Collect all environment information
const envInfo = EnvSnap.collect();
// Get formatted text output
const textReport = EnvSnap.format(envInfo);
// Copy to clipboard
await EnvSnap.copyToClipboard(envInfo);
// Download as file
EnvSnap.download(envInfo, 'my-environment.txt');
// Get as JSON
const jsonData = EnvSnap.toJSON(envInfo);<script src="https://unpkg.com/@watarutmnh/envsnap@latest/dist/index.js"></script>
<script>
const envInfo = EnvSnap.collect();
console.log(EnvSnap.format(envInfo));
</script>| Method | Parameters | Returns | Description |
|---|---|---|---|
EnvSnap.collect() |
β | EnvironmentSnapshot |
Collect all environment information |
EnvSnap.format(data?) |
data (optional) |
string |
Format as human-readable text |
EnvSnap.copyToClipboard(data?) |
data (optional) |
Promise<void> |
Copy formatted info to clipboard |
EnvSnap.download(data?, filename?) |
data, filename (optional) |
void |
Download as text file |
EnvSnap.toJSON(data?) |
data (optional) |
string |
Get as formatted JSON string |
All methods accept an optional data parameter. If omitted, fresh data is collected automatically.
=== Environment Snapshot ===
Generated: 2025-01-20T10:30:00.000Z
Browser
Name: Chrome 120.0
Language: en-US
Online: Yes
Cookies: Enabled
Operating System
OS: macOS 14.2
Platform: MacIntel
64-bit: Yes
Screen
Resolution: 2560 x 1440
Viewport: 1280 x 720
Color Depth: 24-bit
Pixel Ratio: 2
Device
Touch Support: No
Mobile: No
Tablet: No
CPU Cores: 8
Memory: 16 GB
Network
Connection Type: 4g
Downlink: 10 Mbps
RTT: 50 ms
Data Saver: Off
Storage
Local Storage: Yes
Session Storage: Yes
IndexedDB: Yes
Service Worker: Yes
Timezone
Zone: America/New_York
Offset: UTC-5
Locale: en-US
EnvSnap is written in TypeScript and includes full type definitions:
import EnvSnap, { EnvironmentSnapshot, BrowserInfo } from '@watarutmnh/envsnap';
const envInfo: EnvironmentSnapshot = EnvSnap.collect();
const browser: BrowserInfo = envInfo.browser;Visit the live demo to see EnvSnap in action.
# Build
npm run build
# Watch mode
npm run dev
# Type check
npx tsc --noEmit
# Run demo locally
npm run demo- TypeScript β Language
- tsup β Bundler (CJS / ESM / IIFE)
- GitHub Actions β CI/CD
Contributions are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes
- Push to the branch
- Open a Pull Request
MIT