How to add a shader to a ThreeJS geometry in ReactJS
![Oscar de la Hera Gomez](https://www.delasign.com/CDN/headshots/profile.webp)
![Two flowers that represent ReactJS and ThreeJS side by side. Beneath them sits the text "ReactJS & ThreeJS Implement a Shader."](https://www.delasign.com/CDN/images/How-to-add-a-shader-to-a-ThreeJS-geometry-in-ReactJS.webp)
A step by step guide on implementing a shader in a 3JS plane using ReactJS.
We recommend that you clone our Open Source React-Redux Starter Project, checking out the tutorial/three-js/starter branch and carrying out the steps below. The changes can be found on the tutorial/three-js/plane-shader branch.
git clone git@github.com:delasign/react-redux-starter-project.git
Step One: Setup the project
![A screenshot of the app running in a browser. If you change the scale of the screen, the object will adapt accordingly.](https://www.delasign.com/CDN/images/Test_2023-11-06-144953_vxvv.webp)
Follow the tutorial below to setup a responsive ThreeJS, ReactJS project that displays a plane in a scene.
Step Two: Setup the Shader
![A screenshot of VSCode showing the shader functions that we offer in the code below.](https://www.delasign.com/CDN/images/Create-Shader_2023-11-06-155113_qnym.webp)
Create two new files for the vertex and fragment shader and paste in the code below.
Please note we recommend that you place the shader functions in a folder (i.e. sample) within a shaders folder at the root of the project.
Vertex Shader
Fragment Shader
If you are looking for a more advanced solution that implements standard GLSL files, please consult the guide below.
Step Three: Implement the Shader
![A screenshot of VSCode showing the how to implement a shader on a plane in ThreeJS.The code is available below.](https://www.delasign.com/CDN/images/Add-Shader.webp)
Import the shader functions and add them to the plane using code similar to the one below.
Step Four: Test
![A screenshot of Chrome showing that the plane is now using the shader that we offer in this tutorial.](https://www.delasign.com/CDN/images/Test_2023-11-06-155221_iqgu.webp)
Run the code and confirm that the shader looks as expected on the plane.
Looking to learn more about ReactJS and ThreeJS ?
Search our blog to find educational content on learning how to use ReactJS and ThreeJS.