The Frigade JS SDK is a lightweight library that allows you to easily integrate Frigade into any stack that runs Javascript. Unlike the React SDK, it is completely headless and does not include any UI components. Instead, it provides a simple API that allows you to quickly build your own components powered by Frigade with any Javascript framework or library.

1

Install the JS SDK

2

Initialize the SDK

Simply import { Frigade } from '@frigade/js' and initialize the SDK with your public API key from the Developer page of the dashboard.

import { Frigade } from '@frigade/js'

const frigade = new Frigade('FRIGADE_API_KEY')

await frigade.identify('USER_ID', {
  name: 'USER_NAME',
  email: 'USER_EMAIL',
  signed_up_at: 'USER_SIGNED_UP_AT' // ISO 8601 format
})

// Optional: send organization/group id
await frigade.group('ORGANIZATION_ID', {
  name: 'COMPANY_NAME',
})
3

Start building with Frigade

That’s pretty much it! You can now use the Frigade JS SDK. Here’s how to get a Flow:

  const flow = await frigade.getFlow('FLOW_ID')
  console.log('Flow status:', flow.isCompleted)

  const currentStep = flow.getCurrentStep();

  /*
  * You'll usually want to ensure that the flow and current step are both
  * marked as "started" when a user sees them.
  */
  await flow.start();
  await currentStep.start();

  /*
  * Handling interaction is easy -- Flows and Steps have built-in methods
  * to update their state.
  */
  async function handleStepComplete() {
    await currentStep.complete();
  }

We recommend taking a quick look at the JS SDK API documentation to get a better understanding of the available methods and how to use them. Also, check out our guide on building custom components for more information on how to build custom experiences with Frigade.