Score from the browser
Use @langfuse/browser to send frontend feedback scores with only a public key.
Langfuse now ships @langfuse/browser for browser-side score ingestion. Use it to collect thumbs up/down feedback on chat responses, star ratings after generated content, or lightweight client-side quality signals and attach them directly to traces or observations.
The package is intentionally small: initialize LangfuseBrowserClient with your public key and call score(). It sends each score immediately via the ingestion API, so frontend interactions do not need batching or a flush lifecycle. Use @langfuse/client for backend services, scripts, CI jobs, and evaluation pipelines.
npm install @langfuse/browserimport { LangfuseBrowserClient } from "@langfuse/browser";
const langfuse = new LangfuseBrowserClient({
publicKey: process.env.NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY!,
baseUrl: process.env.NEXT_PUBLIC_LANGFUSE_BASE_URL,
});
await langfuse.score({
traceId: message.traceId,
id: `user-feedback-${message.traceId}`,
name: "user-feedback",
value: 1,
dataType: "BOOLEAN",
comment: "Helpful answer",
});Only expose the Langfuse public key in browser code. The secret key remains server-side only.