Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Deno 3 min read How-to mediumAdept

Web Streams at the Edge

Deno Deploy supports the Web Streams standard, so a streaming, event-driven HTTP server can be written in a few lines of TypeScript. Code examples cover an unbuffered HTTP proxy that passes request bodies straight through, a proxy that uppercases response text chunk by chunk with TransformStream, TextDecoderStream and TextEncoderStream, Server-Sent Events built from ReadableStream and setInterval with cleanup on cancel, and WebSockets via Deno.upgradeWebSocket. Because Deno Deploy serves over HTTP/2, SSE avoids the six-connection-per-host browser limit that makes it a poor fit on HTTP/1.1.

Assumes: JavaScript async/awaitHTTP basicsFetch API

Related posts

  • Deno 1.35: A fast and convenient way to build web servers

    Deno mediumAdept

    Deno.serve() is now stable, replacing the connection-iterator Deno.serveHttp() pattern with a one-line handler built on web-standard Request and Response objects. Deno's benchmarks against Node 18.12.1 on a bare-metal Xeon show roughly twice the hello-world throughput, with better tail latency and memory use, and npm packages using node:http get the same speedup. The release also expands Node compatibility (http, https, http2, zlib Brotli), so axios, aws-sdk, puppeteer and astro now work. Other changes include LSP auto-imports for npm and import-map specifiers, an immutable rewrite of std/semver, new std html/entities and http/user_agent modules, V8 11.6 and TypeScript 5.1.6.

  • Deno 1.9 Release Notes

    Deno mediumAdept

    Deno 1.9 adds a native HTTP/2 server API (Deno.serveHttp) built on Hyper, which raises hello-world throughput by 48% over the pure-TypeScript std/http server and reuses fetch's Request/Response objects. Ops between JS and Rust were rebuilt on serde_v8, which serializes directly between V8 and Rust values instead of through JSON or flatbuffers payloads. That change cuts baseline op overhead by up to 98% and makes common functions up to ~3x faster. The release also adds blob: and data: URL support in fetch, ALPN in Deno.listenTls for HTTP/2 over TLS, LSP import completions, allow-lists for --allow-env and --allow-run, and an interactive --prompt permission mode. Several non-system Deno namespace APIs are deprecated and moved to std/io ahead of 2.0.

  • A Whole Website in a Single JavaScript File

    Deno mediumAdept

    A demo multi-page website fits entirely in one JavaScript file and is server-rendered on demand at the edge with Deno. Routing uses a small `router` module built on `URLPattern`, and JSX is rendered server-side with `nanossr`, which styles via twind. Triple-slash reference comments select exactly which TypeScript libs (dom, dom.asynciterable, deno.ns) are loaded. Hosted on Deno Deploy, the site gets a perfect PageSpeed score and is served from 29 data centers over an anycast IP at no cost.

  • Deno 1.12 Release Notes

    Deno mediumAdept

    Deno 1.12 adds Web Crypto key generation, signing and verification, server-side WebSocket upgrades via Deno.upgradeWebSocket on the unstable native HTTP server, and TypeScript transpilation plus automatic static-to-dynamic import conversion in the REPL. It also adds MessageChannel/MessagePort, streaming WebAssembly compilation and instantiation, SharedArrayBuffer and Atomics sharing between workers for WASM threading, and reliable WeakRef/FinalizationRegistry. Smaller changes include console piping to Chrome DevTools, test runner --shuffle and --fail-fast=N flags, per-fetch proxy configuration through Deno.createHttpClient, AbortSignal support in readFile, deprecation of Deno.copy, and an upgrade to V8 9.2.

  • Deno 1.13 Release Notes

    Deno mediumAdept

    Deno 1.13 stabilizes the native HTTP server API (Deno.serveHttp, built on Hyper and dogfooded on deno.land), adds synchronous self.structuredClone() for deep cloning with circular references, and lets TLS trust the system CA store via DENO_TLS_CA_STORE=system, alongside a dangerous --unsafely-ignore-certificate-errors flag. The unstable Rust native plugin system is replaced by an experimental FFI API (Deno.dlopen), because Rust lacks a stable ABI. Other changes include V8 9.3 (Error cause, Object.hasOwn), HMAC support in WebCrypto, type-checking of Markdown code blocks via deno test --doc, AbortSignal in writeFile, and an experimental stream-based WebSocketStream API that addresses backpressure.

The quest for software engineering knowledge.

Look:
Layout: