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, message integrity checks, and configurable security policies.
Zero Dependencies
Lightweight ~54KB 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, reconnection, 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
/**
* 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 reconnection.
*/
import { Parley, SYSTEM_EVENTS } from 'parley-js';
// 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
await parley.broadcast('announcement', { message: 'Update available!' });
~54KB
Minified Bundle
0
Dependencies
100%
TypeScript
85%+
Test Coverage
Enjoying Parley-js?
If this framework has helped you build better applications, consider buying me a coffee to support continued development!