@kansato/whistle-react package provides a React SDK for embedding Whistle report forms with server-side reporter validation. Reports are proxied through your Next.js server, preventing client-side spoofing of reporter information.
Install
Quick setup
1. Create the route handler
Createapp/api/whistle/report/route.ts:
2. Configure environment variables
WHISTLE_API_KEY to the client. Use secret keys (sk_live_) server-side only.
3. Wrap with WhistleProvider
4. Use the component or hook
Component (recommended):Components
WhistleProvider
ReportDialog
Ready-to-use report dialog component with secure submission.
Hooks
useSecureReportSubmission (recommended)
Submits reports through your platform’s server. Reporter information is attached server-side automatically.
useReportSubmission (legacy)
Direct API submission using publishable keys. Less secure — only use if you cannot implement a server-side proxy.
useWhistle()
Low-level hook for opening the hosted report dialog programmatically.
Controlled submission
By default, the report form iframe POSTs directly to your route handler. Pass anonSubmit prop to intercept form data and submit it yourself (server action, custom fetch, etc.).
ReportDialog, ReportForm, and ReportFrame. Its presence enables controlled mode — no extra config needed.
Direct vs controlled
Use controlled mode when you need server actions, custom endpoints, pre-processing, multi-step confirmation flows, or offline queuing.
onSubmit data shape
Handler configuration
Options
getReporter — Auth provider examples
Pass a getReporter function to attach user identity server-side. The client cannot spoof this.
Type signature:
Anonymous reporting
OmitgetReporter. Reports are submitted with an anonymous reporter derived from request IP:
getReportMetadata — Custom metadata
Attach platform-specific context to every report:
userAgent, ip, and timestamp when omitted.
Edge runtime
Addexport const runtime = "edge" to your route file. The handler uses only Web APIs and is fully edge-compatible. Omit for Node.js runtime (default).
Types
IngestSubject
ReportTarget
ReportReasonInput
API keys
Create keys in Settings > Developer > API Keys. Never expose secret keys to the client.
Migration from direct API
If you were usinguseReportSubmission with direct API calls:
Before:
Related guides
- Need keys and auth details? See Developer access.
- Need server-side ingestion? See Node SDK.
- Need a non-React frontend? Use the hosted iframe snippet from Settings > Developer.

