Cogsworth Embed App Client SDK
The Cogsworth Embed App SDK allows Cogsworth partners to embed the Cogsworth Embed application in their own sites with minimal configuration.
Installation
npm install @cogsworthdev/embed-sdk-js
yarn add @cogsworthdev/embed-sdk-js
Usage
One you have set up your secure payload endpoint in your backend, the client SDK can consume it and render the Cogsworth embed application in your site.
In addition to the payload endpoint, you'll need to provide a query selector for the element you wish to render the application in, and your partner ID.
const client = new CogsworthClient({
partnerId: 'xxxxxxxxx',
payloadEndpoint: {
url: `http://partner.com/api/cogsworth-payload?userId=${userId}&clinicId=${clinicId}`,
headers: {},
}
containerSelector: '#cogsworth-widget',
})
Once instantiated, you can call the init()
method to render the Cogsworth embed application.
client.init()
Full example (React)
import CogsworthClient from '@cogsworth4/embed-sdk-js'
const App = () => {
useEffect(() => {
const client = new CogsworthClient({
partnerId: 'xxxxxxxxx',
payloadEndpoint: {
url: `http://partner.com/api/cogsworth-payload?userId=${userId}&clinicId=${clinicId}`,
headers: {},
},
containerSelector: '#cogsworth-widget',
})
client.init()
}, [])
return <div id='cogsworth-widget' />
}