JavaScript and TypeScript
Use this page to check which languages, module formats, packages, and APIs you can rely on in a Cow site.
Cow pages and helpers accept JavaScript with optional TypeScript syntax. Cow removes types before it runs the code. Parsing uses TypeScript 5.9.3. Neither execution nor
cow check performs full type checking.npm packages and modules
Cow resolves installed packages through
node_modules, including package exports and supported aliases. Ordinary packages run within the request’s module environment.| Format | Behavior |
|---|---|
.cow | Code-only imports with optional types and exports. |
.mjs, .ts | ES modules. TypeScript is transpiled. |
.js | ESM or CommonJS, based on the nearest package.json. |
.cjs | CommonJS with request-local module state. |
.json | A request-owned default export. |
Note: Package loading support does not mean that every package works. Dependencies that need blocked process-level APIs or persistent state may need a native adapter.
Web and Node.js APIs
Supported functionality includes
fetch, URL tools, text encoding, Web Crypto, and selected request-safe Node.js file, path, and crypto APIs. Availability in the runtime alone does not make an API available inside a Cow request.What is not promised
- Full Node.js API compatibility or every npm package.
- Raw server, worker, process, watcher, or socket access from ordinary page code.
- Remote HTTP module imports, custom loaders, or TypeScript path remapping.
- A hostile-code sandbox.
- JSX/React or CGI/FastCGI integration as a built-in feature.
Warning: Cow is not a sandbox for hostile code. Run only sites that you trust.
Shared code and saved data
Imports share their evaluated module within a request. A later request gets new ordinary module state. Sessions, database records, and explicitly saved files persist. Native adapters can keep managed connections alive.