reactReact

Setup the SDK

Install Packages

npm install @neonblue-ai/react-bindings

Initialize the SDK

Wrap your application with NeonBlueProvider:

App.jsx
import { NeonBlueProvider } from "@neonblue-ai/react-bindings";

function App() {
  return (
    <NeonBlueProvider
      sdkKey="client--00000000-0000-0000-0000-000000000000"
      user={{ userId: "00000000" }}
    >
      <MyComponent />
    </NeonBlueProvider>
  );
}

For connecting to the staging instance:

You can also pass a pre-initialized client:

Use the SDK

useExperiment Hook

The useExperiment hook fetches an experiment asynchronously and provides loading state:

useNeonBlueClient Hook

Access the client directly for more control:

Changing Users

When a user logs in or out, update the user prop on the provider:

The provider will automatically re-initialize with the new user and fetch fresh experiment assignments.

Loading States

The provider accepts a loadingComponent prop to show while initializing:

Last updated