Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-emulatorjs

dimitrikarpov86ISC2.2.6TypeScript support: included

React wrapper for emulatorjs

react, retroarch, emulator, emulatorjs, nintendo, nes, sega, snes, playstation, gameboy

readme

react-emulatorjs 🕹️

A thing for playing retro games

Button Playground Button NPM Button Gihub Button API

what is emulatorjs

Emulatorjs is a js library to configure and run retro games in web version of retroarch with great UI and features like save states, capturing screenshots, configuring controls, etc... Emulatorjs team did the great job to compile retroarch cores. Check out cores list.

what is react-emulatorjs

react-emulatorjs is a easiest way to use emulatorjs in React with full typescript support including all emulatorjs options. Available cores, available options.

⚡ quick start

Install react-emulatorjs

npm install react-emulatorjs

Next we have to provide url to ROM. It can be somewhere in the internet. Or we can upload a local file. Let's create a file handler to make url to our local blob.

Next we have to select core and start the emulator when the rom is ready.

import { ChangeEvent, useState } from "react"
import { EmulatorJS } from "react-emulatorjs"

function App() {
  const [rom, setRom] = useState<string>()

  const onFileSelect = async (e: ChangeEvent<HTMLInputElement>) => {
    if (!e.target.files?.[0]) return
    const file = e.target.files?.[0]
    setRom(URL.createObjectURL(file))
  }

  return (
    <>
      <input type="file" onChange={onFileSelect} />

      {rom && (
        <EmulatorJS
          EJS_core="nes" // emulator core
          EJS_gameUrl={rom} // rom url
        />
      )}
    </>
  )
}

And thats all! Now You can run nes roms in browser.

Checkout codesandbox demo with this code.

📎 using locally installed cores

The most important option is EJS_pathtodata. This path points to emulatorjs's binaries. And the best performance option is keep them close as possible, on Your sever. And it is very easy.

  • Just extract data folder from latest emulatorjs release and copy in to project's public folder. For example, if You are using 'vite' data folder should be in /public/data.
  • Update prop with new path
    <EmulatorJS
        //...
        EJS_pathtodata="/data"
    />

Docs and examples

changelog

react-emulatorjs

2.2.6

Patch Changes

  • using CDN by default

2.2.5

Patch Changes

  • fix size prop

2.2.4

Patch Changes

  • add height and width params

2.2.3

Patch Changes

    • fix broken library import
    • fix docs links

2.2.2

Patch Changes

  • updated readme file

2.2.1

Patch Changes

  • added EJS_Language option

2.2.0

Minor Changes

  • update default path to data

2.1.1

Patch Changes

  • update README

2.1.0

Minor Changes

  • another README update

2.0.0

Major Changes

  • fbe1b34: update README file

1.0.1

Patch Changes

  • some js files cleanup