New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@typegpu/react

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typegpu/react

The best way to integrate TypeGPU into your React app.

latest
Source
npmnpm
Version
0.12.3
Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

@typegpu/react

Getting Started / Documentation

Basic usage

import { d, common } from 'typegpu';
import { hsvToRgb } from '@typegpu/color';
import { useFrame, useRoot, useUniform, useMirroredUniform, useConfigureContext } from '@typegpu/react';

const App = (props: Props) => {
  const time = useUniform(d.f32);
  const color = useMirroredUniform(d.vec3f, props.color);

  const root = useRoot();
  const renderPipeline = useMemo(
    () =>
      root.createRenderPipeline({
        vertex: common.fullScreenTriangle,
        // Executed per pixel on the GPU 🌈
        fragment: ({ uv }) => {
          'use gpu';
          return hsvToRgb(time.$, uv.x, uv.y) * color.$;
        },
      }),
    [root, time, color]
  );
  
  const { ref, ctxRef } = useConfigureContext();

  // Runs each frame on the CPU 🤖
  useFrame(({ elapsedSeconds }) => {
    if (!ctxRef.current) return;
    
    time.write(elapsedSeconds);
    
    renderPipeline.withColorAttachment({ view: ctxRef.current }).draw(3);
  });

  return <canvas ref={ref} className="absolute inset-0" />;
};

React Native

When react-native-worklets is installed, useFrame callbacks must be worklets and run on the UI thread unless the surrounding Root has disableWorklets enabled. See the React Native Worklets guide for the TypeGPU resources that can be captured and transferred between runtimes.

TypeGPU is created by Software Mansion

swm

Since 2012 Software Mansion is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – Hire us.

Keywords

React

FAQs

Package last updated on 23 Oct 2026

Related posts