0.0.5 • Published 8 months ago

react-inbox-link v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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
  }
}
0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago