To stream Claude output from Amazon Bedrock to a browser, consume Bedrock’s structured event stream in your Node.js server, then translate text deltas into Server-Sent Events (SSE). These are two separate transports: AWS’s JavaScript example documents the Bedrock side, while the server-to-browser SSE layer is application code you must implement and validate for your deployment.
How the two streaming layers fit together
Your server makes a streaming request to Bedrock using the AWS SDK. Bedrock returns structured events, not a plain sequence of text tokens. The server can select text deltas from those events and send them to the browser as SSE messages. The browser-facing stream is therefore a translation layer; it is not Bedrock’s event stream passed through unchanged.
As an Amazon Associate I earn from qualifying purchases.
| Layer | What it carries | What to verify |
|---|---|---|
| Bedrock to Node.js | Structured events from ConverseStream, including text deltas and lifecycle or other content events. |
Confirm that the selected model supports streaming in the region you will use. AWS recommends checking GetFoundationModel and its responseStreamingSupported value. AWS ConverseStream API reference |
| Node.js to browser | SSE messages that your application creates from events it chooses to expose. | Implement and test the HTTP response framing, headers, disconnect handling, and any proxy or hosting behavior for your Node.js and browser setup. |
Consume Claude’s Bedrock stream with the JavaScript SDK
AWS’s JavaScript SDK v3 example imports BedrockRuntimeClient and ConverseStreamCommand from @aws-sdk/client-bedrock-runtime, sends the command with client.send(), and reads response.stream using asynchronous iteration. The following illustrates that documented upstream pattern; it is not a complete Node.js HTTP server or browser-ready SSE implementation.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →import { BedrockRuntimeClient, ConverseStreamCommand } from "@aws-sdk/client-bedrock-runtime";
const client = new BedrockRuntimeClient({ region: "us-east-1" });
const command = new ConverseStreamCommand({
modelId: "anthropic.claude-3-haiku-20240307-v1:0",
messages: [
{
role: "user",
content: [{ text: "Explain how SSE works in one paragraph." }],
},
],
inferenceConfig: {
maxTokens: 512,
temperature: 0.5,
topP: 0.9,
},
});
try {
const response = await client.send(command);
for await (const item of response.stream) {
const text = item.contentBlockDelta?.delta?.text;
if (text !== undefined) {
// Pass this text to your application's downstream SSE layer.
process.stdout.write(text);
}
}
} catch (error) {
// Handle request-time and stream-consumption failures here.
console.error("Bedrock ConverseStream failed:", error);
}
The model ID and region in this sample are examples, not universal defaults. Availability and streaming support depend on the model and region you choose. The example’s maxTokens, temperature, and topP are also sample inference settings, not requirements or recommended values for every application. See AWS’s JavaScript SDK v3 Bedrock Runtime examples and ConverseStream API reference.
#1 Best Overall
Handle events by type, not as plain text
A Bedrock response stream can contain message-start, content-block, message-stop, and metadata events. Content blocks can include start, delta, and stop events; a delta may carry text, reasoning, or partial tool-use JSON. The code above extracts only the text field from a content-block delta. That is suitable only when your application intends to expose text and does not need to process other event types.
- Text deltas: Select
contentBlockDelta.delta.textwhen present and pass it to your chosen downstream representation. - Tool use: A content block may identify tool use and stream partial JSON. Do not display those fragments as ordinary prose or assume each fragment is a complete JSON value.
- Reasoning and other data: Deltas may carry non-text content. Decide explicitly what your application should do with each event shape.
- Lifecycle and metadata: Message and content-block boundaries, stops, and metadata are part of the structured stream; they are not user-facing text tokens.
AWS describes the event sequence and content-block behavior in its Converse API inference guide. Build event handling around the shapes your application supports rather than assuming every yielded item contains displayable text.
Rank #2
Map selected deltas to SSE in your Node.js application
The SDK example establishes how to read Bedrock events; it does not specify how to frame an HTTP response for browser EventSource clients. Treat SSE as a separate server implementation. For each selected text delta, your server must encode and write an SSE message according to the current Node.js and browser documentation, and it must finish or signal the client appropriately when the Bedrock stream ends or fails.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteBefore deploying, validate the details for your stack: response headers and event framing, behavior when the client disconnects, and whether a reverse proxy or hosting platform buffers the response. Do not assume that receiving chunks from Bedrock guarantees they will arrive incrementally in the browser. The code above deliberately writes to standard output and should not be mistaken for a tested SSE route or browser client.
Rank #3
Handle failures at request time and during streaming
Failure can occur while sending the command or after the stream has begun. AWS documents response-stream errors including internal server errors, model stream errors, model timeouts, service unavailability, throttling, and validation errors. See the ResponseStream API reference.
- Wrap both
client.send(command)and asynchronous stream iteration in error handling, as the example does. - If an upstream error happens after you have started the downstream response, stop producing normal content and communicate an application-appropriate failure to the client. Do not leave the browser waiting for a stream that can no longer complete.
- Decide how your server responds when a browser disconnects, including whether and how to stop upstream work. Validate cancellation behavior with the SDK and server code you deploy; the cited Bedrock examples do not define your HTTP disconnect policy.
- Do not promise automatic recovery or retry behavior unless your application implements and tests it.
Check model and tooling support before shipping
Use ConverseStream for models that support Bedrock’s message API, and verify streaming support for the specific model and region rather than inferring it from another model’s example. AWS also notes that the AWS CLI does not support Bedrock streaming operations such as ConverseStream; use an SDK or another supported integration for this streaming workflow. AWS ConverseStream API reference
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




