API reference
Exports, types, and low-level options for @deck-io/feedback and @deck-io/feedback/server.
API reference
Package: @deck-io/feedback (current: 0.2.0+)
Entries
| Import path | Runtime | Description |
|---|---|---|
@deck-io/feedback | Browser / React | Provider, built-in UI, hooks, client submit |
@deck-io/feedback/server | Node / server | createDeckFeedbackClient, server-safe submit (no React) |
Client entry (@deck-io/feedback)
Components and hooks
| Export | Kind | Description |
|---|---|---|
DeckProvider | Component | Auth, user, theme, URL capture, submit context |
useDeckFeedback | Hook | Raw context (submitFeedback, user, apiUrl, …) |
useSubmitFeedback | Hook | Headless submit + loading/error state |
FeedbackDialog | Component | Controlled feedback modal |
ThumbsFeedback | Component | Thumbs control → dialog flow |
submitFeedback | Function | Low-level client (works without React when you pass key + user) |
FEEDBACK_SENTIMENTS | Const | ["negative", "neutral", "positive"] |
DEFAULT_WIDGET_API_URL | Const | Production widget ingest URL |
SDK_VERSION | Const | Package version string (e.g. "0.2.0") |
Theming helpers
| Export | Description |
|---|---|
DECK_FEEDBACK_CSS_VARS | Map of token names → CSS custom properties |
DECK_FEEDBACK_DEFAULT_THEMES | Built-in light/dark token sets |
themeTokensToCssVars | Convert token object to React CSS properties |
resolveColorScheme | Resolve light | dark | system |
getDeckFeedbackBaseStylesheet | Base CSS string for built-in widgets |
Client types
| Type | Description |
|---|---|
DeckUser | { id: string; email?: string; name?: string } |
DeckFeedbackUrlCapture | "path" | "full" | "none" |
FeedbackSentiment | "positive" | "neutral" | "negative" |
FeedbackContext | Record<string, string | number | boolean | null | undefined> |
FeedbackSubmission | Full ingest payload shape |
FeedbackSubmissionMeta | url?, userAgent?, sdkVersion?, occurredAt?, source? |
FeedbackSubmitResponse | FeedbackSubmitResult | FeedbackSubmitError |
FeedbackSubmitResult | { ok: true; submissionId?: string } |
FeedbackSubmitError | { ok: false; error: string; status?: number } |
DeckProviderProps | Provider props |
FeedbackDialogProps | Dialog props |
ThumbsFeedbackProps | Thumbs props |
DeckFeedbackContextValue | Context value |
SubmitFeedbackInput | Headless hook input |
SubmitFeedbackOptions | Low-level submitFeedback options |
DeckFeedbackColorScheme | "light" | "dark" | "system" |
DeckFeedbackThemeTokens | Theme token overrides |
Server entry (@deck-io/feedback/server)
Import this path from Route Handlers, Server Actions, Express/Fastify routes, or workers. It does not load React.
| Export | Kind | Description |
|---|---|---|
createDeckFeedbackClient | Function | Reusable server client; defaults meta.source to "server" |
submitFeedback | Function | Same low-level submit as the client entry |
DEFAULT_WIDGET_API_URL | Const | Production widget ingest URL |
SDK_VERSION | Const | Package version string |
Server types
| Type | Description |
|---|---|
CreateDeckFeedbackClientOptions | { publishableKey: string; apiUrl?: string } |
DeckFeedbackClient | { submit(input): Promise<FeedbackSubmitResponse> } |
DeckFeedbackClientSubmitInput | { user; submission; meta? } |
SubmitFeedbackOptions | Low-level options (includes optional meta override) |
DeckUser, FeedbackSentiment, FeedbackContext, FeedbackSubmission, FeedbackSubmissionMeta, FeedbackSubmitResult, FeedbackSubmitError, FeedbackSubmitResponse | Shared payload / response types |
createDeckFeedbackClient
import { createDeckFeedbackClient } from "@deck-io/feedback/server";
const deck = createDeckFeedbackClient({
publishableKey: process.env.DECK_PUBLISHABLE_KEY!,
// apiUrl?: optional override
});
await deck.submit({
user: { id: "user_1", email: "a@b.com" },
submission: {
widgetId: "wgt_...",
sentiment: "negative",
message: "Checkout failed",
context: { endpoint: "/api/checkout" },
},
meta: {
url: request.headers.get("referer") ?? undefined,
},
});Behavior:
- Sets
urlCaptureto"none"(no browser inference) - Merges
metawith default{ source: "server" }(your fields win on conflict)
Full guide: Server-side submit.
Low-level submitFeedback options
Available from both @deck-io/feedback and @deck-io/feedback/server:
type SubmitFeedbackOptions = {
publishableKey: string;
apiUrl?: string;
urlCapture?: DeckFeedbackUrlCapture; // default "path" (use "none" on the server)
user: DeckUser;
submission: {
widgetId: string;
sentiment: FeedbackSentiment;
message?: string;
context?: FeedbackContext;
};
/** Override auto-generated metadata (url, userAgent, occurredAt, source). */
meta?: Partial<FeedbackSubmissionMeta>;
};Client-side validation errors
Returned as { ok: false, error: string } without a network call when:
| Condition | error |
|---|---|
| Missing publishable key | Missing publishable key |
Missing user.id | user.id is required |
Missing widgetId | widgetId is required |
Missing sentiment | sentiment is required |
Network and API failures return { ok: false, error, status? } with a message from the response body when available.
Default ingest URL
DEFAULT_WIDGET_API_URL points at Deck production widget feedback ingest
(https://api.getdeck.io/api/v1/widgets/feedback).
Override with apiUrl on the provider, server client, or low-level options only when Deck directs you to.