0.26.0 • Published 2 years ago

@frontend-sdk/rebuy v0.26.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Rebuy

Rebuy integration for Shogun Frontend.

Rebuy creates intelligent shopping experience with data-driven persoanlization and providing merchandizing solutions.

Rebuy website →

Installation

yarn add @frontend-sdk/rebuy

npm install @frontend-sdk/rebuy


Rebuy Widgets

Inject Rebuy's script with your Shopify domain (….myshopify.com):

import { useRebuyWidget } from '@frontend-sdk/rebuy'

const RebuyWidget = ({ widgetId }) => {
  useRebuyWidget('<insert Shopify domain>')

  return (
    <div
      data-rebuy-id="widgetId"
      data-rebuy-shopify-product-ids="<Product ID>"
    </div>
  )
}

Rebuy Data

You can also manually display data from any of Rebuy's API endpoints.

Please include an API key as a query string, e.g. https://rebuyengine.com/api/v1/products/recommended?key={insert_key_here}. You may view your keys here. For more information, visit Rebuy's documentation here.

import { useRebuyData } from '@frontend-sdk/rebuy'

const RebuyData = () => {
  const { loading, error, data } = useRebuyData('<endpoint>')

  if (loading) {
    return <h1>Loading…</h1>
  }
  if (typeof error !== 'undefined') {
    return <h1>Error</h1>
  }
  if (typeof data === 'undefined') {
    return <h1>Wrong data</h1>
  }

  return (
    <>
      <ul>
        {data.data.map((product) => (
          <li key={product.title}>{product.title}</li>
        ))}
      </ul>
    </>
  )
}

Links