🌍 Environment Support
Our library is designed to be truly universal, ensuring that you can use the same code across all modern runtimes.
📊 Compatibility Matrix
| Environment | Supported Versions | Note |
|---|---|---|
| Node.js | >= 18.0.0 | Polyfill required for Node 18 |
| Browsers | All modern browsers | Native |
| Bun | >= 1.0.0 | Native |
| Deno | >= 1.0.0 | Native |
🛠️ Node.js 18 Support
To use features like uuid or randomBytes in Node.js 18, you must manually polyfill the webcrypto API as it is not available globally in that version.
Add this at the top of your entry file (e.g., index.js, server.js, or main.ts):
import crypto from 'node:crypto';
if (typeof globalThis.crypto === 'undefined') {
Object.defineProperty(globalThis, 'crypto', {
value: crypto.webcrypto,
writable: true,
configurable: true,
});
}We bring modern language features and APIs to your environment, allowing you to write future-proof code today without polluting the global namespace (except when manual polyfills are required).
🚀 Future-Proof Design
The @opentf/std library is built using modern ESM standards and leverages native platform APIs wherever possible. By choosing this library, you are ensuring that your code:
- Runs Everywhere: Seamlessly move logic between Edge, Server, and Browser.
- Remains Lightweight: Zero external dependencies and full tree-shaking support.
- Stays Modern: We use the latest JavaScript features while providing stable fallbacks for the environments you need to support.