@napi-rs/canvas exposes Google Skia drawing to Node.js via Node-API with prebuilt binaries, portable text rendering, and PNG and JPEG export options.
Overview
The skr canvas project (published as @napi-rs/canvas) binds Google Skia to Node.js through Node-API so server and tooling code can render images and graphics without relying on system canvas libraries. Prebuilt packages target common CPU architectures on Linux, macOS, and Windows, with documented glibc requirements on Linux and notes for AWS Lambda via a separate layer.
API behavior aligns with familiar canvas workflows: drawing paths, text, and images, encoding to buffers or files, and optional metadata such as DPI and author fields in PNG and JPEG output. Text can use a portable FreeType renderer for consistent pixels across operating systems, or a system renderer mode that follows platform font stacks similar to browser behavior. Font registration, fallback rules, and SVG text handling are documented in detail.
PathKit utilities support path operations such as unions and differences on beziers and conics. The library suits image generation in Node services, PDF or asset pipelines, and deployments like Vercel where native dependencies are undesirable.
Consumers install via npm and import the package into JavaScript or TypeScript applications; it is not a standalone desktop or browser application.
Key features
- Skia rendering via Node-API
- Zero system canvas dependencies
- PNG and JPEG encode with metadata
- Portable and system text renderers
- Custom font registration
- Path2D and PathKit operations
- Prebuilt binaries for major OS targets
- AWS Lambda layer support documented
Use cases
- Server-side image generation
- Node chart and thumbnail rendering
- Lambda graphics without native deps
- Automated visual test output