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
fullthey point at Bun’s native implementations. - In
litethey point at Tynd’s polyfills (tungstenite-backedWebSocket,ureq-backedfetch,@noble/*-backedcrypto.subtle, etc.).
Behavior follows the Web spec in both runtimes — the same app code runs
unchanged across full and lite.
Exports
| Group | Exports |
|---|---|
| Fetch | fetch, Request, Response, Headers, AbortController, AbortSignal, ReadableStream |
| Sockets | WebSocket, EventSource |
| Crypto | crypto (with crypto.subtle, crypto.randomUUID, crypto.getRandomValues) |
| URL + encoding | URL, URLSearchParams, TextEncoder, TextDecoder, atob, btoa |
| Binary data | Blob, File, FormData |
| Misc | structuredClone, 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.compute—hash(blake3/sha2) andrandomBytesvia Rust, ~3–10× faster thancrypto.subtleon lite.
Related
- Runtimes — full vs lite parity matrix.
- Architecture — where polyfills fit.
Last updated on