Skip to Content

web

import * as web from "@tynd/core/client/web"; // or grab individual exports: import { fetch, crypto, URL } from "@tynd/core/client/web";

Standard Web-platform globals, re-exported so they’re discoverable in the @tynd/core/client surface next to the Tynd OS APIs.

  • In full they point at Bun’s native implementations.
  • In lite they point at Tynd’s polyfills (tungstenite-backed WebSocket, ureq-backed fetch, @noble/*-backed crypto.subtle, etc.).

Behavior follows the Web spec in both runtimes — the same app code runs unchanged across full and lite.

Exports

GroupExports
Fetchfetch, Request, Response, Headers, AbortController, AbortSignal, ReadableStream
SocketsWebSocket, EventSource
Cryptocrypto (with crypto.subtle, crypto.randomUUID, crypto.getRandomValues)
URL + encodingURL, URLSearchParams, TextEncoder, TextDecoder, atob, btoa
Binary dataBlob, File, FormData
MiscstructuredClone, performance

Example

import { fetch, crypto, URL } from "@tynd/core/client/web"; import { fs } from "@tynd/core/client"; export async function downloadAndHash(url: string, dest: string) { const res = await fetch(url); const bytes = new Uint8Array(await res.arrayBuffer()); // Web-standard SubtleCrypto — available on lite via polyfill. const digest = await crypto.subtle.digest("SHA-256", bytes); const hex = [...new Uint8Array(digest)] .map((b) => b.toString(16).padStart(2, "0")) .join(""); // Tynd OS API on the same namespace. await fs.writeBinary(dest, bytes); return hex; }

When to prefer the Tynd APIs

These re-exports are pure Web-standard. Use them when you want spec-conformant behavior and portability to browser code.

For workloads that benefit from a Rust-native fast path, prefer the dedicated Tynd APIs:

  • http — request retries, download-with-progress events, no CORS.
  • websocket — dedicated thread per session, auto-reconnect helpers.
  • computehash (blake3/sha2) and randomBytes via Rust, ~3–10× faster than crypto.subtle on lite.
Last updated on