react-inbox-link
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

react-inbox-link

The React bindings for the LinkToInbox.com API offering both component and hook interfaces encapsulating the standard Web Component and JavaScript API interfaces respectively.

This package also has TypeScript support for a smoother integration.

npm install react-inbox-link

Usage

The component API:

import { InboxLink } from 'react-inbox-link'

function Example() {
  return (
    <InboxLink
      publishableKey="pk_YOUR_KEY"
      recipientAddress="user@example.com"
    />
  )
}

The hook API:

import { useInboxLink } from 'react-inbox-link'

function Example() {
  const inboxLink = useInboxLink('pk_YOUR_KEY', {
    recipientAddress: 'user@example.com',
  })

  switch (inboxLink.type) {
    case 'loading':
      return <p>Loading…</p>
    case 'link_not_available':
      if (inboxLink.error) {
        console.error(inboxLink.error)
      }
      return null
    case 'link_data':
      const { link, icon, providerName } = inboxLink.data
    // Render how you'd like
  }
}

Readme

Keywords

Package Sidebar

Install

npm i react-inbox-link

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

8.99 kB

Total Files

11

Last publish

Collaborators

  • andrejewski