Skip to main content
Version: Current

Simple Example

In the following example, we'll be rendering a Unity Application in our React Application. A fixed height and width is provided to the canvas in order to keep the aspect ratio of the Unity Application.

import React from "react";import { Unity, useUnityContext } from "react-unity-webgl";function App() {  const { unityProvider } = useUnityContext({    loaderUrl: "build/myunityapp.loader.js",    dataUrl: "build/",    frameworkUrl: "build/myunityapp.framework.js",    codeUrl: "build/myunityapp.wasm",  });  return (    <Unity unityProvider={unityProvider} style={{ width: 800, height: 600 }} />  );}