Installation
HTVG is available in multiple formats to suit your development environment. Choose the installation method that matches your project.- Node.js / WASM
- Rust
- CLI
JavaScript/TypeScript via npm
Install HTVG as a dependency in your Node.js, browser, or edge runtime project.Browser Usage
The WASM module auto-fetches the.wasm file in browser environments:The
init() function must be called once before using any compilation functions. In browsers, it automatically fetches the WASM module.Node.js Usage
For Node.js, you need to explicitly load the WASM file:Cloudflare Workers
For Cloudflare Workers and other edge runtimes, import the WASM module directly:Verify Installation
After installation, verify HTVG is working correctly:System Requirements
- Rust: Rust 1.70 or higher
- Node.js: Node.js 18 or higher (for WASM usage)
- WASM: WebAssembly support in target environment
Troubleshooting
WASM Module Not Found
If you see “WASM module not found” errors in Node.js:- Ensure you’re passing the WASM buffer to
init() - Verify the path to
htvg_bg.wasmis correct - Check that the file exists in
node_modules/htvg/dist/wasm/
Rust Compilation Errors
If you encounter compilation errors:- Update Rust to the latest stable version:
rustup update - Clear the build cache:
cargo clean - Rebuild:
cargo build
Type Errors in TypeScript
If you see TypeScript errors:- Ensure you have the latest version:
npm update htvg - Check that your
tsconfig.jsonincludes"module": "ESNext"or"NodeNext"
Next Steps
Quick Start Guide
Now that HTVG is installed, follow our quick start guide to build your first project