react-inbox-link
v0.0.5
Published
React bindings for the LinkToInbox API
Downloads
4
Readme
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="[email protected]"
/>
)
}
The hook API:
import { useInboxLink } from 'react-inbox-link'
function Example() {
const inboxLink = useInboxLink('pk_YOUR_KEY', {
recipientAddress: '[email protected]',
})
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
}
}