Skip to content

React Integration

Add FeedValue to your React application.

Installation

bash
npm install @feedvalue/react

Basic Usage

tsx
import { FeedValueWidget } from '@feedvalue/react';

function App() {
  return (
    <div>
      <FeedValueWidget widgetId="wgt_abc123" />
    </div>
  );
}

Props

PropTypeDefaultDescription
widgetIdstringrequiredYour widget ID
positionstring'bottom-right'Widget position
themestring'auto''light', 'dark', or 'auto'
primaryColorstring-Custom primary color
onOpenfunction-Called when widget opens
onClosefunction-Called when widget closes
onSubmitfunction-Called after feedback submitted

Example with All Props

tsx
import { FeedValueWidget } from '@feedvalue/react';

function App() {
  return (
    <FeedValueWidget
      widgetId="wgt_abc123"
      position="bottom-left"
      theme="dark"
      primaryColor="#7c3aed"
      onSubmit={(feedback) => {
        console.log('Feedback submitted:', feedback);
      }}
    />
  );
}

Programmatic Control

tsx
import { useFeedValue } from '@feedvalue/react';

function FeedbackButton() {
  const { open, close, isOpen } = useFeedValue();

  return (
    <button onClick={open}>
      {isOpen ? 'Close' : 'Give Feedback'}
    </button>
  );
}

TypeScript Support

Full TypeScript support is included:

tsx
import type { FeedValueProps, FeedbackData } from '@feedvalue/react';

const handleSubmit = (feedback: FeedbackData) => {
  // feedback.message, feedback.sentiment, etc.
};

TIP

The React package automatically handles cleanup on unmount and prevents memory leaks.

Built with care by SarverEnterprises