WebGPUjs (v0.0.30) is a JavaScript library that enables writing full-featured WGSL pipelines directly in JavaScript, without requiring separate shader files. It provides a high-level API for allocating buffers, uniforms, textures, and specifying compute, vertex, and fragment shaders. Key features include automatic binding combination, support for compute shaders with multiple output buffers, chaining of shader stages, and instance VBOs. As an early-stage project (pre-v1), it breaks often and lacks comprehensive docs. It competes with raw WebGPU API and wgpu-native bindings, focusing on developer ergonomics for rapid prototyping. Release cadence is irregular; expect breaking changes.
npm install webgpujsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebGPU compute pipeline that doubles each element of a 1024-element float32 array using a WGSL shader.
Use await GPU.create() or .then().
Replace buffer type strings with { type: 'storage', ... }.Access result via .read() on the returned buffer.
Wrap code in an entry point function (e.g., @compute @workgroup_size(64) fn main(...)).
Ensure buffer sizes are multiples of 4.
Replace with 'const gpu = await GPU.create();'
Check that pipeline code is valid and that GPU device is still available.
Wrap your compute logic in a function with @compute attribute.
Run in a recent Chrome/Edge or Firefox nightly; ensure WebGPU enabled.
No dependency data recorded yet.