Getting started (public beta)
Public Beta
The Flex SDK is currently available as a Public Beta product and the information contained in this document is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Public Beta products are not covered by a SLA.
Not a HIPAA Eligible Service or PCI Compliant
The Flex SDK is not a HIPAA Eligible Service or PCI compliant and should not be used in workflows that are subject to HIPAA or PCI.
To get started with the Flex SDK, you'll need to use a Flex account or add Flex to your Twilio account. If you're new to Flex, see the onboarding guide to get started or learn more about Flex pricing.
Use the following steps to develop a Flex SDK application. We'll use the vite framework here, but the Flex SDK also supports TypeScript and JavaScript.
- Create a directory for the new Flex SDK application.
- If you haven't already installed vite, run
npm install -g vite. - Run
npm create vite@latest. - Follow the wizard, and choose a vanilla project with TypeScript as the programming language.
- Navigate into the newly created project folder and install the Flex SDK.
- Run
npm i @twilio/flex-sdk. - Run
vitewithnpm run dev. This runs the vite application with the Flex SDK installed.
In order to use Flex in a code file, include the Flex SDK and initialize the client. While we recommend using SSO, you can also use an auth token like the example below:
1import { createClient } from "@twilio/flex-sdk";23async function createFlexClient(tokenForWorker: string) {4const client = await createClient(tokenForWorker, {5logger: { level: "debug" }});6return client;7}
To embed the Flex SDK into an existing application, navigate to the project directory and execute the following command:
npm i @twilio/flex-sdk
This adds the Flex SDK to the project, after which you can import and initialize clients.