Features Examples Documentation GitHub Get Started
v1.1.0 Released

postMessage
Made Simple

Type-safe, robust framework for window, tab, and iframe communication. Zero dependencies, full TypeScript support, security-first design.

npm install ignite-parleyjs

Built for Production

Everything you need for secure cross-window communication

Security-First

Origin validation, protocol validation, and configurable security policies.

Zero Dependencies

Lightweight ~55 KB minified (~16 KB gzipped) bundle. Pure, efficient JavaScript with no bloat.

Full TypeScript

Complete type safety with generics and excellent IDE support.

Request/Response

Timeout handling, automatic retries, and response correlation.

Connection Lifecycle

Heartbeat monitoring, connection-loss detection, and state management.

Schema Validation

JSON Schema validation for message payloads. Catch errors early.

Simple, Intuitive API

Get started in minutes with a clean, well-documented API

View All Examples Live HTML Examples
/**
 * Parent Window Example
 * 
 * Demonstrates embedding an iframe and establishing secure two-way
 * communication. Parley-js handles the complexity of postMessage:
 * origin validation, response correlation, timeouts, and connection-loss detection.
 */
import { Parley, SYSTEM_EVENTS } from 'ignite-parleyjs';

// Create instance with origin validation
const parley = Parley.create({
    targetType: 'iframe',
    allowedOrigins: ['https://child.example.com'],
    timeout: 5000,
});

// Handle incoming notifications from child
parley.on('notification', (payload, respond, metadata) => {
    console.log(`Child says: ${payload.message}`);
});

// Connect to iframe and assign target ID
const iframe = document.querySelector('#child-iframe');
await parley.connect(iframe, 'child');

// Send message and get typed response
const response = await parley.send('hello', { name: 'World' }, {
    targetId: 'child'
});
console.log(response.greeting); // "Hello, World!"

// Broadcast to all connected targets (fire-and-forget, no responses)
parley.broadcast('announcement', { message: 'Update available!' });

~16KB

Gzipped Bundle

0

Dependencies

100%

TypeScript

~80%

Test Coverage

Enjoying Parley-js?

If this framework has helped you build better applications, consider buying me a coffee to support continued development!