DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to write a custom WebGPU component with defineShader with Shaders

Define a new effect with props and a WGSL pixel function, then mount it like any other component.

Short answer: Read the Custom Components guide at https://shaders.com/docs/guide/custom-shaders and the Primitives reference; then create a file that imports defineShader, wgsl, transformColor, and transformPosition from 'shaders/std'; Define the component with a name, a props object with defaults and transforms, and a paint wgsl block. All steps.

  • Content
  • Advanced
  • 60 minutes
  • From the README
  • Any agent

Who it is forAn experienced front-end or graphics developer who needs an effect that the built-in library does not provide.

The problemOff-the-shelf components may not match a specific visual, and building a GPU effect from nothing is costly.

The outcomeA reusable custom component with typed props, mounted in a page alongside the built-in effects.

What you need first

  • Node.js and npm to install the shaders package
  • A project using React, Vue, Svelte, Solid, or plain JavaScript
  • A browser with WebGPU support for the effects to render
  • A free shaders.com account if you want to use the design editor or CLI sync

Steps

  1. Read the Custom Components guide at https://shaders.com/docs/guide/custom-shaders and the Primitives reference.
  2. Create a file that imports defineShader, wgsl, transformColor, and transformPosition from 'shaders/std'.
  3. Define the component with a name, a props object with defaults and transforms, and a paint wgsl block.
  4. Mount the new component in your page the same way as a built-in component and check the rendered output.

Prompt for your agent

In the shader-effects-inc/shaders repo, write a custom defineShader component named <component-name> in <project-path> that draws <effect-description>. Expected output: one new component file and a page that mounts it. Verify that the wgsl paint block returns a vec4f and that the props match the defaults.

Caveat. The README marks composing from std primitives as experimental and writing WGSL directly as stable, so prefer the WGSL route for production work.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for shader-effects-inc/shaders and "Write a custom WebGPU component with defineShader"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer