flagfish-client-react
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

FlagFish React Client

FlagFish React Client is a lightweight React package for working with FlagFish feature flags. It allows your frontend app to easily fetch feature flag configurations via a simple POST API using React context and hooks.

✨ Features

  • 🔐 API key authentication via provider
  • ⚙️ Configurable base URL
  • 📡 Sends POST requests with optional payload
  • 🚀 Hook-based API (useFlag)
  • 🧠 Built-in AbortController for request cancellation

📦 Installation

npm install flagfish.client.react

**Usage:

import React from "react";
import { FlagFishProvider, useFlag } from "flagfish.client.react";

const App = () => (
  <FlagFishProvider apiKey="your-api-key">
    <MyComponent />
  </FlagFishProvider>
);

const MyComponent = () => {
  const { data, loading, error, trigger } = useFlag({
    endpoint: "/api/flags",
    data: { userId: "123" },
    autoRun: true, // Optional: trigger request on mount
  });

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return <pre>{JSON.stringify(data, null, 2)}</pre>;
};

Readme

Keywords

none

Package Sidebar

Install

npm i flagfish-client-react

Weekly Downloads

25

Version

0.0.6

License

MIT

Unpacked Size

9.58 kB

Total Files

5

Last publish

Collaborators

  • flagfishdotco