# @veri5ied/react-postmessage

> cross-origin communication with postmessage

Latest version **1.0.3** (published 2023-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @veri5ied/react-postmessage
pnpm add @veri5ied/react-postmessage
yarn add @veri5ied/react-postmessage
bun add @veri5ied/react-postmessage
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-03-22 |
| First published | 2023-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alvin Okoro |
| Maintainers | veri5ied |

## Links

- npm: https://www.npmjs.com/package/@veri5ied/react-postmessage
- npm.io page: https://npm.io/package/@veri5ied/react-postmessage

## Recent versions

- 1.0.3 (latest) — 2023-03-22
- 1.0.2 — 2023-03-22
- 1.0.1 — 2023-03-22
- 1.0.0 — 2023-03-20

## README

# react-postmessage

Cross-Origin Communication with post message for react applications

## Usage

### Post message hook for sending data from child to parent window

Usage:

```
const postMessage = usePostMessage();
postMessage({ type: 'message', payload: 'hello' });
```

```
const postMessage = usePostMessage({ targetOrigin: '\*' });
postMessage({ type: 'message', payload: 'hello' });
```

```
const postMessage = usePostMessage({ targetOrigin: 'http://localhost:3000' });
postMessage({ type: 'message', payload: 'hello' });
```

### Receive message hook for receiving data from parent window

Usage:

```
const receiveMessage = useReceiveMessage();
receiveMessage((message) => {
console.log(message);
});
```

```
const receiveMessage = useReceiveMessage({ targetOrigin: '\*' });
receiveMessage((message) => {
console.log(message);
});
```

---
_Source: https://npm.io/package/@veri5ied/react-postmessage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
