npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gpujs/expo-gl

v1.0.0

Published

Use GPU.js for native GPGPU in Expo / React Native, via expo-gl

Readme

@gpujs/expo-gl

CI

Use GPU.js for native GPGPU in Expo / React Native, on top of expo-gl.

Installation

npx expo install expo-gl
npm install gpu.js @gpujs/expo-gl

expo-gl and gpu.js are peer dependencies, so your app controls their versions. This package adds no dependencies of its own.

Usage

Expo creates GL contexts asynchronously, so obtain one and hand it to GPU. Write kernels as strings, not functions — see below.

import { GLView } from 'expo-gl';
import { GPU } from '@gpujs/expo-gl';

const context = await GLView.createContextAsync();
const gpu = new GPU({ context });

const kernel = gpu.createKernel(`function kernelFunction(a, b) {
  return a[this.thread.x] + b[this.thread.x];
}`).setOutput([3]);

kernel([1, 2, 3], [4, 5, 6]); // Float32Array [5, 7, 9]

Kernels must be strings

React Native runs on Hermes, which discards function source. Calling toString() on a function returns a placeholder:

function add(a, b) { return a + b; }
add.toString(); // "function add(a0, a1) { [bytecode] }"

GPU.js compiles a kernel by reading its source, so a kernel passed as a function cannot work here — it fails with Identifier is not defined on line 1. Strings are unaffected, and GPU.js accepts them everywhere it accepts a function, including addFunction().

This is not a limitation of this package and cannot be worked around from it: Hermes is the only engine Expo ships as of SDK 53, so there is no engine to switch to.

A context from a rendered <GLView onContextCreate={...} /> works equally well.

Everything else — kernel settings, textures, createKernelMap — is plain GPU.js; see the GPU.js documentation, keeping in mind that any kernel or added function must be given as a string.

Releasing the context

A headless context from createContextAsync() is yours to clean up:

import { ExpoGLKernel } from '@gpujs/expo-gl';

await GLView.destroyContextAsync(context);
ExpoGLKernel.reset(); // forget it, so a later context is picked up

Requirements

  • A WebGL2-capable Expo GL context. expo-gl provides one on iOS and Android; this package is not for web, where GPU.js runs directly.
  • A real device or simulator. There is no Node implementation of Expo's GL, so kernels cannot run under test — CI covers wiring only.

Notes

This package never creates a context of its own. Contexts are asynchronous and expensive, and creating one at import time — as versions before 1.0.0 did — raced with support detection, leaked the context, and cost startup time in apps that never touched the GPU. Feature detection is likewise deferred until something asks for it, since it compiles and runs a probe kernel.

Expo's contexts come from the native side and are not instances of any WebGL2RenderingContext class, which React Native does not define, so this package recognises them structurally rather than with instanceof.