{"id":13401702,"url":"https://github.com/gre/gl-react","last_synced_at":"2025-10-20T01:49:20.540Z","repository":{"id":36601353,"uuid":"40907506","full_name":"gre/gl-react","owner":"gre","description":"gl-react – React library to write and compose WebGL shaders","archived":false,"fork":false,"pushed_at":"2023-07-19T05:34:44.000Z","size":134711,"stargazers_count":2959,"open_issues_count":57,"forks_count":163,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-05-14T11:51:38.007Z","etag":null,"topics":["glsl","react","react-native","universal","webgl"],"latest_commit_sha":null,"homepage":"https://gl-react-cookbook.surge.sh","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-08-17T15:49:51.000Z","updated_at":"2025-05-03T08:02:15.000Z","dependencies_parsed_at":"2024-02-09T05:15:20.294Z","dependency_job_id":null,"html_url":"https://github.com/gre/gl-react","commit_stats":null,"previous_names":[],"tags_count":80,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gre","download_url":"https://codeload.github.com/gre/gl-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270656,"owners_count":22042860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["glsl","react","react-native","universal","webgl"],"created_at":"2024-07-30T19:01:06.011Z","updated_at":"2025-10-20T01:49:15.486Z","avatar_url":"https://github.com/gre.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/gre/gl-react.svg?branch=master)](https://travis-ci.org/gre/gl-react) [![npm](https://img.shields.io/npm/v/gl-react.svg)](https://www.npmjs.com/package/gl-react)\n\n# \u003cimg width=\"32\" alt=\"icon\" src=\"https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png\"\u003e gl-react (v4)\n\n`gl-react` is a [React](https://facebook.github.io/react/) library to write and compose WebGL shaders. _Implement complex effects by composing React components._\n\nThis universal library must be coupled with one of the concrete implementations:\n\n- [`gl-react-dom`](packages/gl-react-dom/) for React DOM (backed by WebGL).\n- [`gl-react-native`](packages/gl-react-native/) for React Native (iOS/Android OpenGL, backed by [Expo implementation](https://docs.expo.io/versions/latest/sdk/gl-view.html) over unimodules).\n- [`gl-react-expo`](packages/gl-react-expo/) for React Native (iOS/Android OpenGL, backed by [Expo implementation](https://docs.expo.io/versions/latest/sdk/gl-view.html)).\n- [`gl-react-headless`](packages/gl-react-headless/) for Node.js (backed by [headless-gl](https://github.com/stackgl/headless-gl))\n\n## Links\n\n- **[Cookbook, examples, API](https://gl-react-cookbook.surge.sh)**\n- [Expo Cookbook](https://expo.io/@gre/gl-react)\n- [JSFiddle hello gl example](https://jsfiddle.net/greweb/cup5feke/)\n- [![Join the chat at https://gitter.im/gl-react/Lobby](https://badges.gitter.im/gl-react/Lobby.svg)](https://gitter.im/gl-react/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## References\n\n- [GLSL spec](https://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf)\n- ['the books of shaders'](https://thebookofshaders.com)\n- [shader-school workshop](https://www.npmjs.com/package/shader-school)\n\n## They use gl-react 🙂\n\n\u003c!-- alphabetic order --\u003e\n\n- [onthisspot.ca](https://www.reddit.com/r/reactnative/comments/4ucgdq/just_launched_my_first_iosandroid_app_thanks/)\n- [ProjectSeptember](http://greweb.me/2016/07/projectseptember-opengl/)\n- [WallGen](https://szymonkaliski.github.io/wallgen/)\n- [noisesculptor.com](http://www.noisesculptor.com/)\n- _... your project ?_\n\n## Gist\n\n```js\nimport React from \"react\";\nimport { Shaders, Node, GLSL } from \"gl-react\";\nconst shaders = Shaders.create({\n  helloBlue: {\n    frag: GLSL`\nprecision highp float;\nvarying vec2 uv;\nuniform float blue;\nvoid main() {\n  gl_FragColor = vec4(uv.x, uv.y, blue, 1.0);\n}`\n  }\n});\nclass HelloBlue extends React.Component {\n  render() {\n    const { blue } = this.props;\n    return \u003cNode shader={shaders.helloBlue} uniforms={{ blue }} /\u003e;\n  }\n}\n```\n\nimport the correct implementation,\n\n```js\nimport { Surface } from \"gl-react-dom\"; // for React DOM\nimport { Surface } from \"gl-react-expo\"; // for React Native via Expo GLView\nimport { Surface } from \"gl-react-native\"; // for React Native\nimport { Surface } from \"gl-react-headless\"; // for Node.js!\n```\n\nand this code...\n\n```js\n\u003cSurface width={300} height={300}\u003e\n  \u003cHelloBlue blue={0.5} /\u003e\n\u003c/Surface\u003e\n```\n\n...renders:\n\n![](https://cloud.githubusercontent.com/assets/211411/9386550/432492c6-475c-11e5-9328-f3d5187298c1.jpg)\n\n## Features\n\n- **React, VDOM and immutable paradigm**: OpenGL is a low level imperative and mutable API. This library takes the best of it and exposes it in an immutable, descriptive way with React.\n- **React lifecycle** allows partial GL re-rendering. Only a React Component update will trigger a redraw. Each Node holds a framebuffer state that get redrawn when component updates and schedule a Surface reflow.\n- **Developer experience**\n  - React DevTools works like on DOM and allows you to inspect and debug your stack of effects.\n- **Uniform bindings**: bindings from JavaScript objects to OpenGL GLSL language types (bool, int, float, vec2, vec3, vec4, mat2, mat3, mat4, sampler2D...)\n- An **extensible texture loader** that allows to support any content that goes in the shader as a sampler2D texture.\n  - support for images\n  - support for videos (currently `gl-react-dom`)\n  - support for canvas (`gl-react-dom`)\n- **flowtype** support.\n- Modular, Composable, Sharable. Write shaders once into components that you re-use everywhere! At the end, users don't need to write shaders.\n\n## Atom nice GLSL highlighting\n\nIf you are using Atom Editor, you can have JS inlined GLSL syntax highlighted.\n\n![](https://cloud.githubusercontent.com/assets/211411/20623048/0527cce2-b306-11e6-85ee-5020be994c10.png)\n\n**To configure this:**\n\n- add `language-babel` package.\n- Configure `language-babel` to add `GLSL:source.glsl` in settings \"_JavaScript Tagged Template Literal Grammar Extensions_\".\n- (Bonus) Add this CSS to your _Atom \u003e Stylesheet_:\n\n```css\n/* language-babel blocks */\natom-text-editor::shadow .line .ttl-grammar {\n  /* NB: designed for dark theme. can be customized */\n  background-color: rgba(0, 0, 0, 0.3);\n}\natom-text-editor::shadow .line .ttl-grammar:first-child:last-child {\n  display: block; /* force background to take full width only if ttl-grammar is alone in the line. */\n}\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgre%2Fgl-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgre%2Fgl-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgre%2Fgl-react/lists"}