Skip to main content
Version: 7.x.x (Maintenance LTS)

Getting Started

// Get started by creating a new React
// component and importing the libraries!

import React from "react";
import Unity, { UnityContent } from "react-unity-webgl";

export class App extends React.Component {
constructor(props) {
super(props);

// Next up create a new Unity Content object to
// initialise and define your WebGL build. The
// paths are relative from your index file.

this.unityContent = new UnityContent(
"MyGame/Build.json",
"MyGame/UnityLoader.js"
);
}

render() {
// Finally render the Unity component and pass
// the Unity content through the props.

return <Unity unityContent={this.unityContent} />;
}
}