vt-feedback
v0.2.0
Published
Client SDK for submitting feedback to a VTHub instance, plus a themeable React feedback widget.
Readme
vt-feedback
Client SDK for submitting feedback to a self-hosted VTHub instance.
Install
npm install vt-feedback
# or
pnpm add vt-feedbackSetup
Every project points at the same VTHub instance, so set its URL once as an environment variable instead of passing it everywhere:
# .env.local
NEXT_PUBLIC_VTHUB_API_URL=https://vthub.yourdomain.comapiUrl can still be passed explicitly (e.g. to point at localhost in dev,
or override per-environment) — it takes priority over the environment
variable when provided.
Framework-agnostic core
import { submitFeedback } from 'vt-feedback'
const result = await submitFeedback(
{ apiKey: process.env.NEXT_PUBLIC_VTHUB_API_KEY! },
{ category: 'bug', message: 'Saving fails on mobile Safari' },
)React widget
import { FeedbackWidget } from 'vt-feedback/react'
import 'vt-feedback/react/styles.css'
export function App() {
return (
<FeedbackWidget
apiKey={process.env.NEXT_PUBLIC_VTHUB_API_KEY!}
theme={{ colorPrimary: '#7c3aed', radius: '10px' }}
/>
)
}apiKey is a per-project key created in the VTHub dashboard. It is safe to expose client-side — it only permits creating feedback submissions for that one project. Unlike apiUrl, it's not a good fit for a shared environment variable since it's different per project.
Build
npm run build