How to create a ThreeJS responsive ReactJS project

Oscar de la Hera Gomez
Two flowers that represent ReactJS and ThreeJS side by side. Beneath them sits the text "ReactJS & ThreeJS Responsive Starter Project."

A step by step guide on creating a 3JS ReactJS project that updates its scene as the screen scales.

We recommend that you clone our Open Source React-Redux Starter Project, checking out the main branch and carrying out the steps below. The changes can be found on the tutorial/three-js/starter branch.

git clone git@github.com:delasign/react-redux-starter-project.git

Please note that the repository has been setup to work with React Redux.

To learn how we did this, please consult the tutorial linked below.

Please note that if you are seeking to use GLSL shaders we strongly recommend that you upgrade to a ReactJS project that uses ViteJS.

Step One: Install the Dependencies

A screenshot of Terminal showing us running the line of code detailed below.

Open Terminal and set the current directory to that of the project.

Subsequently, add the Three JS dependency and its types using the line below:

yarn add three; yarn add @types/three;

Step Two: Create the Scene

A screenshot of VSCode showing the code for the ThreeJS scene. The code is found below.

Create a new typescript file called Scene.tsx and paste in the code below.

We recommend that you create this scene component under a Components/3JS folder.

Step Three: Add the Scene to the App

A screenshot of VSCode showing how we added the scene to the ReactJS app.

Add the scene to the render function of the App.tsx file.

Step Four: Test

A screenshot of the app running in a browser. If you change the scale of the screen, the object will adapt accordingly.

Run the project and confirm that the scene works as expected.

Looking to learn more about ReactJS and ThreeJS ?

Search our blog to find educational content on learning how to use ReactJS and ThreeJS.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details