Choose Your SDK
Mirador provides two SDKs depending on your environment:
Web SDK
For browser-based applications
Node.js SDK
For server-side applications
SDKs for Python, Go, Rust, and other languages are currently in development. Contact us if you’re interested in early access.
Web SDK
Install the Mirador Web SDK for browser-based applications:
npm install @miradorlabs/web-sdk
Initialize the Web Client
import { Client } from '@miradorlabs/web-sdk';
const client = new Client('your-api-key');
Node.js SDK
Install the Mirador Node.js SDK for server-side applications:
npm install @miradorlabs/nodejs-sdk
Initialize the Node.js Client
import { Client } from '@miradorlabs/nodejs-sdk';
const client = new Client('your-api-key');
Configuration
Custom Gateway URL
If you’re using a self-hosted gateway or different environment:
Web SDK:
import { Client } from '@miradorlabs/web-sdk';
const client = new Client('your-api-key', {
apiUrl: 'https://your-gateway.example.com:443'
});
Node.js SDK:
import { Client } from '@miradorlabs/nodejs-sdk';
const client = new Client('your-api-key', {
apiUrl: 'https://your-gateway.example.com:443'
});
Custom Keep-Alive Interval
Both SDKs support configurable keep-alive intervals:
const client = new Client('your-api-key', {
keepAliveIntervalMs: 15000 // Ping every 15 seconds (default: 10000)
});
Debug Mode and Plugins
v2 introduces new client options:
import { Client, Web3Plugin } from '@miradorlabs/web-sdk';
const client = new Client('your-api-key', {
debug: true, // Enable debug logging
plugins: [Web3Plugin({ provider: window.ethereum })], // Blockchain integration
sampleRate: 0.5 // Record 50% of traces
});
See Client Options for the full list of configuration options.
The Web SDK provides multiple module formats:
| Format | File | Use Case |
|---|
| ESM | dist/index.esm.js | Modern bundlers (Webpack, Vite, Rollup) |
| UMD | dist/index.umd.js | Browser globals, older module systems |
| TypeScript | dist/index.d.ts | Type definitions |
ESM Import
import { Client } from '@miradorlabs/web-sdk';
CDN / Browser Global
Load the SDK directly from a CDN — no bundler required:
<script src="https://unpkg.com/@miradorlabs/web-sdk@2.0.0/dist/index.umd.js"></script>
Then use the MiradorWeb global:
<script>
const client = new MiradorWeb.Client('your-api-key');
</script>
Pin to a specific version (e.g. @2.0.0) in production to avoid unexpected breaking changes.
Browser Requirements
The SDK requires modern browser features:
- ES2020+ - Modern JavaScript syntax
- Fetch API - For network requests
- Promises - For async operations
Supported Browsers
| Browser | Minimum Version |
|---|
| Chrome | 80+ |
| Firefox | 75+ |
| Safari | 13.1+ |
| Edge | 80+ |
Polyfills
For older browsers, you may need to include polyfills:
npm install core-js whatwg-fetch
import 'core-js/stable';
import 'whatwg-fetch';
import { Client } from '@miradorlabs/web-sdk';
Verifying Installation
Test that the SDK is working:
Web SDK:
import { Client } from '@miradorlabs/web-sdk';
const client = new Client('your-api-key');
const trace = client.trace({ name: 'TestTrace' })
.addEvent('installation_verified');
console.log('Web SDK installed successfully!');
Node.js SDK:
import { Client } from '@miradorlabs/nodejs-sdk';
const client = new Client('your-api-key');
const trace = client.trace({ name: 'TestTrace' })
.addEvent('installation_verified');
console.log('Node.js SDK installed successfully!');
Next Steps
Quickstart
Build your first trace