How Deno Embraces Web Standards and Future‑Proofs Your Code
The JavaScript ecosystem has spent years reinventing the same primitives: HTTP clients, request/response objects, cryptography APIs, and more. Every platform had its own flavor, its own types, and its own incompatibilities. That fragmentation makes code harder to share, harder to reason about, and harder to migrate.
Web standards—like fetch, Request, Response, URL,
WebSocket, and WebCrypto—offer a common language. If your code speaks that
language, it can move between browsers, edge runtimes, and servers with minimal friction.
Deno leans into this idea aggressively: instead of inventing new APIs, it adopts the ones the web already agreed on.
Deno’s core philosophy: use the platform, not a framework
Deno treats the web platform as the standard library. When you write Deno code, you’re mostly using the same primitives you’d use in a browser or a worker environment. That means fewer custom abstractions and fewer runtime‑specific hacks.
- HTTP: Built on
Request,Response, andfetch. - URLs: Uses the standard
URLandURLSearchParamsclasses. - Crypto: Uses
crypto.subtlefrom the WebCrypto spec. - WebSockets: Uses the standard
WebSocketinterface.
The result is that Deno code feels less like “backend JavaScript” and more like “web JavaScript that happens to run on the server.”
Example: HTTP servers with standard Request and Response
Here’s a minimal HTTP server in Deno that uses the same Request and Response types
you’d see in a Service Worker or Cloudflare Worker:
/// server.ts
Deno.serve((req: Request): Response => {
const url = new URL(req.url);
if (url.pathname === "/") {
return new Response("Hello from Deno using web standards!", {
status: 200,
headers: { "content-type": "text/plain; charset=utf-8" },
});
}
return new Response("Not found", { status: 404 });
});
If you’ve written code for edge platforms like Cloudflare Workers or browser Service Workers, this will look instantly familiar. The mental model is the same: a request comes in, you return a response.
Example: Shared logic between browser and server
Because Deno uses web APIs, you can often share logic between client and server with almost no changes. For example, URL parsing and query handling can be identical:
// shared/url.ts
export function getUserIdFromUrl(urlString: string): string | null {
const url = new URL(urlString);
return url.searchParams.get("userId");
}
In the browser:
// browser.ts
import { getUserIdFromUrl } from "./shared/url.ts";
const userId = getUserIdFromUrl(window.location.href);
console.log("User ID in browser:", userId);
In Deno:
// server.ts
import { getUserIdFromUrl } from "./shared/url.ts";
Deno.serve((req: Request) => {
const userId = getUserIdFromUrl(req.url);
return new Response(`User ID on server: ${userId}`);
});
Same function, same API, two environments. That’s the power of standards.
WebCrypto in Deno: secure by specification
Cryptography is another area where fragmentation has historically hurt portability. Deno exposes the
crypto.subtle API, just like modern browsers, so you can implement hashing, signing, and
encryption with the same interface on both sides.
// crypto-example.ts
const encoder = new TextEncoder();
const data = encoder.encode("hello deno");
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, "0")).join("");
console.log("SHA-256 hash:", hashHex);
This code runs in Deno and in a modern browser with no changes. If a future platform implements WebCrypto, your code is already compatible.
Portability across runtimes and vendors
When your code is written against web standards, you’re less tied to any single vendor or runtime. Today you
might run on Deno Deploy; tomorrow you might move to another edge platform or a different server runtime that
also supports fetch and friends.
Instead of rewriting your app around a proprietary API, you can keep most of your logic intact and only swap out the thin integration layer where needed. That’s a huge win for long‑term maintainability.
In other words, Deno doesn’t just make your code run now—it makes it easier for your code to keep running when the ecosystem shifts.