@bigloupe/react
v0.3.3
Published
BigLoupe React adapter — <BigLoupeProvider> + useBigLoupe() with the BigLoupe browser SDK bundled in
Readme
@bigloupe/react
React adapter for the BigLoupe feedback SDK. Thin wrapper over
@bigloupe/sdk — handles init/teardown via a provider and exposes an imperative
hook.
Install
npm i @bigloupe/reactUsage
Wrap your app once. The SDK initializes on mount and shuts down on unmount (StrictMode-safe).
import { BigLoupeProvider } from '@bigloupe/react';
export function App({ children }) {
return (
<BigLoupeProvider
config={{
dsn: 'https://bigloupe.example.com/v1/ingest/p/pk_xxx',
env: 'staging',
widget: { label: 'Feedback', position: 'bottom-right' },
privacy: { maskAllInputs: true },
}}
>
{children}
</BigLoupeProvider>
);
}useBigLoupe()
import { useBigLoupe } from '@bigloupe/react';
function Profile({ user }) {
const { identify, setContext, open, captureFeedback } = useBigLoupe();
useEffect(() => {
identify({ id: user.id, email: user.email, name: user.name });
setContext('plan', user.plan);
}, [user]);
return <button onClick={open}>Report a problem</button>;
}| Method | Description |
| --- | --- |
| identify(user) | Attach/update the current user identity. |
| setContext(key, value) | Add arbitrary context sent with feedback. |
| open() | Open the feedback widget programmatically. |
| captureFeedback(fb) | Submit feedback without the widget (captures a fresh screenshot). |
Keep it out of production
Gate the provider so it never ships to real customers:
if (process.env.NEXT_PUBLIC_BIGLOUPE_ENABLED !== 'true') return <>{children}</>;