Skip to main content
flexprice/react-example is a small React application that uses the TypeScript SDK end to end: it creates the client, sends usage events from user actions, and renders usage analytics for the signed-in customer. Use it to see the shape of a working integration before wiring your own, or as a scratch app for testing a sandbox environment.

The example app stack

Running the example app

1

Clone and install

2

Configure

Fill in the variables with values from a sandbox environment:
Use https://api.cloud.flexprice.io/v1 if your tenant is in the India region.
3

Start

Open http://localhost:5173.
The example reads the API key in the browser through Vite environment variables so it can run with no backend. That is fine for a local demo against a sandbox key and wrong for anything deployed. A production app keeps the key on a server. See Harden client-side access.

What to look at in the example app

  • Client setup. Where the SDK is constructed once and shared through the app.
  • Sending events. The handlers that call events.ingestEvent when a user takes a billable action, including the properties they attach.
  • Reading usage. The queries that fetch usage analytics and customer data and feed them to charts.
Once the flow makes sense, swap the demo’s direct SDK calls for the pattern in Fetch entitlements and usage on the client and render with the UI kit.

flexprice/react-example

Using the SDKs