Skip to main content
@flexprice/ui is the Flexprice UI kit: the React components the Flexprice dashboard itself renders, published from flexprice-front as one package with pricing, usage, and credits widgets. Every component is presentational. It takes props and renders; you decide where the data comes from. This page covers installation per framework. Fetch entitlements and usage on the client covers the data.

What the UI kit package ships

Installing in React (Vite, CRA, or any SPA)

Import the stylesheet once at the root, then use components anywhere:

Installing in Next.js

The components render on the server and hydrate on the client. Import the stylesheet in the root layout (App Router) or _app.tsx (Pages Router).
Components that take callbacks (onSelectPlan, onBillingPeriodChange) need a client boundary:
Fetch the data in a Server Component and pass it down, so the API key never reaches the browser:

Installing in Remix and Astro

Both work with the same two steps: import the stylesheet once (in root.tsx for Remix, in the layout for Astro) and pass data from a loader or frontmatter into the component. In Astro, add client:load to components with callbacks so they hydrate:

Installing in plain HTML (no bundler)

The CommonJS file is also a UMD bundle, so a page with no build step can load React, ReactDOM, and the kit from <script> tags and reach the components on the FlexpriceUI global:
Pin versions in production instead of loading the latest tag, and serve the files from your own origin if you would rather not depend on a public CDN.

Using the kit with Vue, Svelte, and other frameworks

There is no Vue or web-component build of the kit. Two options work now:
  • Mount a React island. Render the component into a container with react-dom. The island is self-contained, so it works inside a Vue or Svelte page.
  • Use the data, not the components. Fetch entitlements and usage as described in Fetch entitlements and usage on the client and render them with your own markup.
A React island bundled once and dropped into any page:

Theming the installed components

Components read CSS variables declared on the .flexprice-ui element. Override --primary with HSL channels, and add the dark class to any ancestor for dark mode:
See Theming for the full variable list and the ancestor caveat.

Map API data with the exported adapters

The kit exports adapter functions that turn raw Flexprice API responses into each component’s prop shape, and normalize* functions that validate untrusted data at runtime before rendering: Each component page documents the adapter and the API endpoint it expects. Start from the UI kit overview.

Next steps with the UI kit

Fetch data on the client

Portal sessions and backend proxies.

Harden client access

Keep keys server-side and cache safely.

Components

Every component with a live preview.