npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

liaison-react

v0.0.14

Published

React hook library for Liaison

Readme

Liaison React SDK

liaison-core is a wrapper on the browser postMessage API, which allows windows and embedded iframes to securely send messages and data using CORS.

  • Please reference this library for more information on the core API.

liaison-react exports React hooks that can be used to utilize this library in a more Reacty way.

Parent Model in Action

// ... App.tsx
import { useState } from 'react';
import { useParent } from 'liaison-react';
import { nanoid } from 'nanoid';

import './App.css'

function timeout(ms: number) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

function App() {
  const [logoutRequests, setLogoutRequests] = useState(0);

  const { callIFrameEffect } = useParent({
    iframe: {
      id: 'my-embedded-iframe',
      src: 'http://localhost:3002',
    }
    effects: {
      logout: () => {
        setLogoutRequests(prevNumber => prevNumber + 1);
      },
      sendToken: ({ callIFrameEffect }) => {
        const token = nanoid();
        callIFrameEffect({
          name: 'saveToken',
          args: {token},
        });
      },
      sendTokenAsync: async ({ callIFrameEffect }) => {
        await timeout(3000);
        const token = nanoid();
        callIFrameEffect({
          name: 'saveToken',
          args: {token},
        });
      }
    }
  })

  return (
    <>
      <h1>Parent Window</h1>
      <div className='buttons'>
        <p>Request to run events within the iFrame!</p>
        <button onClick={initiateChildLogout}>
          Initiate <em>Child</em> Logout Process
        </button>
      </div>
      <div>
        <h2>Logout Requests:</h2>
        <p>{logoutRequests}</p>
      </div>
      <div id="my-embedded-iframe-container">
        <iframe id="my-embedded-iframe" src="http://localhost:3002" className="iframe"></iframe>
      </div>
    </>
  )

  function initiateChildLogout() {
    callIFrameEffect({ name: 'logout', args: {} });
  }
}

export default App

// ... main.tsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)

IFrame Model in Action

// ... App.tsx
import { useState } from 'react';
import { useIFrame } from 'liaison-react';
import './App.css'

function App() {
  const [logoutRequests, setLogoutRequests] = useState(0);
  const [tokens, setTokens] = useState<Array<string>>([]);

  const { callParentEffect } = useIFrame({
    parentOrigin: 'http://localhost:3003',
    effects: {
      logout: () => setLogoutRequests(prevNum => prevNum + 1),
      saveToken: ({ args: { token } }) => {
        setTokens(prevTokens => [...prevTokens, token]);
      },
      saveTokenAsync: ({ args: { token } }) => {
        setTokens(prevTokens => [...prevTokens, token]);
      },
    }
  })

  return (
    <>
      <h1>Child Window</h1>
      <div className="buttons">
        <p className="buttons-header">Request to run events within the Parent window!</p>
        <button onClick={initiateParentLogout} className="btn">Initiate <em>Parent</em> Logout Process</button>
        <button onClick={requestTokenFromParent} className="btn">Request Token from Parent (Get Synchronously)</button>
        <button onClick={requestTokenFromParentAsync} className="btn">Request Token from Parent (Get Asynchronously)</button>
      </div>
      <div>
        <h2>Logout Requests:</h2>
        <p>{logoutRequests}</p>
        <h2>Tokens:</h2>
        <ul>
          {tokens.map((token) => <li key={token}>Token: {token}</li>)}
        </ul>
      </div>
    </>
  )

  function initiateParentLogout() {
    callParentEffect({
      name: 'logout',
    })
  }

  function requestTokenFromParent() {
    callParentEffect({
      name: 'sendToken',
    })
  }

  function requestTokenFromParentAsync() {
    callParentEffect({
      name: 'sendTokenAsync',
    })
  }

}

export default App

// ... main.tsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)