mycover.ai
  • Home
  • Distributor
  • 🚀Getting Started
    • Quickstart
    • Environments
    • Authentication
    • Testing
    • Errors
    • Go Live Checklist
    • FAQs
  • 🔌Libraries & SDKs
    • Javascript
    • Vue 2
    • Vue 3
    • React
    • Flutter
    • Android
    • React Native
    • iOS
  • 📦api reference
    • Products
      • 🚘Auto
        • Aiico
        • Leadway
        • MyCoverGenius
        • Sovereign Trust
        • Coronation
        • Tangerine
        • Sanlam
      • ♥️Health
        • Hygeia
          • Hyprime Insurance
          • Hybasic Insurance
        • Bastion
          • Bastion Health
          • MediSure
        • Malaria Cover
      • 💞Personal Accident Cover
        • Aiico
        • Leadway
        • Sanlam
      • 🏠Content (Home/Office)
        • Aiico
        • Coronation
        • Sanlam
      • ✈️Travel
        • Allianz
        • Aiico
      • 💵Life Insurance
        • Credit Life
        • SME Flex
        • Flex Life
      • 🚚Goods In Transit
        • Goods In Transit (GIT)
        • Goods In Transit (GIT) On-demand
      • 💻Gadget
        • Sovereign Trust Insurance
        • Coronation
        • Tangerine
      • 🛳️Marine Insurance ✨
        • MyCoverGenius Import Marine Cover
        • Marine Cover
    • Policies
    • Claims
      • Credit Life
    • Wallet
    • Transactions
    • Customers
    • Auxiliary
      • Products
        • Bulk Purchase
  • 🧳Services
    • Webhooks
      • Validation
      • Purchase Webhook
      • Renewal Webhook
    • Messaging
Powered by GitBook
On this page
  • Installation
  • Usage
  • Styling
  • Next.js
  • Component props

Was this helpful?

  1. Libraries & SDKs

React

Is your team using React.js? We've got you covered!

Installation

With NPM

npm install @mycoverai/mca-react-sdk

From CDN

<script src="https://unpkg.com/@mycoverai/mca-react-sdk/dist/umd.js"></script>

Usage

Import in your template and setup your business configuration by supplying your public key. If product_id is not provided or is an empty array, the SDK will display a list of insurance products for the customer to choose from. You can supply an array of strings, where each string represents an insurance product's id, for the user to select from.

//import package
import { Mca } from '@mycoverai/mca-react-sdk'

<Mca
  publicKey="MCAPUBK_TEST|1acf339a-d36f-47e7-8e1b-fd0b86b61b0d"
>
  Buy Insurance
</Mca>

Styling

The Mca component is flexible and lets you add any element as children or parent. To style your CTA, see this example using TailwindCSS:

<Mca
  publicKey="MCAPUBK_TEST|1acf339a-d36f-47e7-8e1b-fd0b86b61b0d"
>
   <button className="w-[300px] h-[56px] bg-green-700 text-white font-medium rounded-md">
       Buy Insurance
    </button>
</Mca>

Next.js

Component props

Prop
Type
Required
Description

productId

Array<string>

No

UID of the product(s). If product_id is not provided or is an empty array, the SDK will display a list of insurance products for the customer to choose from.

publicKey

string

Yes

Your public key. Get it from your Mycover.ai distributor dashboard.

callback

function

No

A function to call once a user completes a purchase.

onClose

function

No

A function to call if the user aborts the process by closing the SDK widget.

form

object

No

Use this prop if you want to initialize the SDK with predefined information from your customer. E.g email, first_name, last_name, etc.

landingUrls

string[]

No

Provide up to 2 optional custom landing page urls after your customers purchase a product or complete a claim.

interface Config {
    productId?: Array<String>
    publicKey: string,
    callback?: () => void,
    onClose?: () => void,
    form?: object,
    landingUrls?: string[];
}
PreviousVue 3NextFlutter

Last updated 1 year ago

Was this helpful?

By default, Next uses universal (client-side + server-side) rendering to render your application. Client rendering is opt-in, meaning you have to explicitly decide what components React should render on the client. If you attempt to render the Mca component without using the "use client" directive, it will result in an error. See for more information.

🔌
documentation