# moroboxai-player-react

> MoroboxAI player for React

Latest version **0.1.0-alpha.25** (published 2023-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install moroboxai-player-react
pnpm add moroboxai-player-react
yarn add moroboxai-player-react
bun add moroboxai-player-react
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.25 |
| Published | 2023-11-02 |
| First published | 2022-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | moroboxai |
| Maintainers | moroboxai |
| Keywords | moroboxai, player, react |

## Links

- npm: https://www.npmjs.com/package/moroboxai-player-react
- Repository: https://github.com/moroboxai/moroboxai-player-react
- Homepage: https://github.com/moroboxai/moroboxai-player-react#readme
- Issues: https://github.com/moroboxai/moroboxai-player-react/issues
- npm.io page: https://npm.io/package/moroboxai-player-react

## Dependencies (5)

- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [moroboxai-game-sdk](https://npm.io/package/moroboxai-game-sdk.md) ^0.1.0-alpha.36
- [moroboxai-player-web](https://npm.io/package/moroboxai-player-web.md) ^0.1.0-alpha.29
- [moroboxai-editor-react](https://npm.io/package/moroboxai-editor-react.md) ^0.1.1-alpha.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0-alpha.25 (latest) — 2023-11-02
- 0.1.0-alpha.24 — 2023-11-01
- 0.1.0-alpha.23 — 2023-11-01
- 0.1.0-alpha.22 — 2023-10-20
- 0.1.0-alpha.21 — 2023-10-15
- 0.1.0-alpha.20 — 2023-10-08
- 0.1.0-alpha.19 — 2023-10-08
- 0.1.0-alpha.18 — 2023-09-22
- 0.1.0-alpha.17 — 2023-09-20
- 0.1.0-alpha.16 — 2023-09-16
- 0.1.0-alpha.15 — 2023-09-16
- 0.1.0-alpha.14 — 2023-09-16
- 0.1.0-alpha.13 — 2023-09-14
- 0.1.0-alpha.12 — 2023-09-14
- 0.1.0-alpha.11 — 2023-09-14
- … 9 more at https://npm.io/package/moroboxai-player-react/versions

## README

# moroboxai-player-react

[![NPM version](https://img.shields.io/npm/v/moroboxai-player-react.svg)](https://www.npmjs.com/package/moroboxai-player-react)
![Node.js CI](https://github.com/moroboxai/moroboxai-player-react/workflows/Node.js%20CI/badge.svg)
[![gitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/moroboxai/moroboxai-player-react/blob/master/LICENSE)
[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/moroboxai/moroboxai-player-react.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/moroboxai/moroboxai-player-react/context:javascript)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/moroboxai/moroboxai-player-react.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/moroboxai/moroboxai-player-react/alerts)

Embeddable player for running [MoroboxAI](https://github.com/moroboxai) games in [React](https://reactjs.org/).

## Installation

Using npm:

```bash
npm install moroboxai-player-react --save
```

Or:

```bash
git clone https://github.com/moroboxai/moroboxai-player-react.git
cd moroboxai-player-react
npm i
npm run build
```

## Usage

Setup a simple React app with:

```bash
npx create-react-app my-app --template typescript
```

Add `moroboxai-player-react` as a dependency:

```bash
cd my-app
npm install moroboxai-player-react --save
```

Replace `src/App.tsx` with:

```javascript
import "./App.css";
import Player from "moroboxai-player-react";

function App() {
    return (
        <div className="App">
            <header className="App-header">
                <Player
                    url="https://raw.githubusercontent.com/moroboxai/moroboxai-games/master/games/pong/"
                    splashart="https://raw.githubusercontent.com/moroboxai/moroboxai-games/master/games/pong/assets/splashart.png"
                    width={256}
                    height={256}
                />
            </header>
        </div>
    );
}

export default App;
```

Build and start a local server to see the result:

```bash
npm run build
npm run start
```

## Props

| Name      | Type    | Default | Description                                                                                          |
| :-------- | :------ | :------ | :--------------------------------------------------------------------------------------------------- |
| url       | string  |         | URL of the game                                                                                      |
| splashart | string  |         | URL of the placeholder image displayed before the game is loaded                                     |
| width     | number  |         | Width of the `div` element                                                                           |
| height    | number  |         | Height of the `div` element                                                                          |
| resizable | boolean | true    | If the game can resize the player                                                                    |
| className | string  |         | Class name for the `div` container                                                                   |
| autoPlay  | boolean | false   | Auto play the game after the player is initialized                                                   |
| speed     | number  | 1       | Speed of the game                                                                                    |
| onReady   | func    | noop    | **Signature: function() => void** <br/> Function called when the game is loaded and ready            |
| onMount   | func    | noop    | **Signature: function(player: IPlayer) => void** <br/> Function called when the component is mounted |

## License

This content is released under the [MIT](http://opensource.org/licenses/MIT) License.

---
_Source: https://npm.io/package/moroboxai-player-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
