A step by step guide on setting up a new A-Frame project in React

A-Frame is a great way to get into developing VR, especially for those who come from a Javascript background. For those who dont know what A-Frame is, here is the official description taken directly from the first paragraph of “What is A-Frame” on their website:

A-Frame is a web framework for building virtual reality (VR) experiences. As originators of WebVR, the Mozilla VR team developed A-Frame to be the easiest as well as the most powerful way to develop WebVR content. As a fully open project, A-Frame has grown to be one of the largest and most welcoming VR communities.

The purpose of this tutorial is to help you get started with A-Frame as quickly as possible so you don’t have to waste time figuring out how to set up. If you already have react set up, skip to the last part. Here is a link to github if you want to see the final setup.

If you want to see their official docs, click on this link.

Step one: Create an empty repository

In this tutorial, we’ll call this project vr-hello-world. For creating folders, you can use the mkdir command in terminal or the right-click>new folder.

Step 2: Create a file structure

In project, there will be two main components, a client and a server. So create two folders and name it ‘client’ and ‘server’.

Since this project will use webpack to bundle the react code, add another two folders into the client folder, and name them ‘src’ and ‘dist

Step 3: Creating the Server

This will create a Node/Express server that will serve the client whenever the url is called.

Now run yarn start in the terminal and you should see listening on port 5000! in the console.

Step 4: React and Webpack

Now we can get started on the client side.

Step 5: Set up A-Frame

Now go to localhost:5000 and this should render on the page:

That’s it. Have fun hacking in VR!