# @metastore/react

> React package for integrating game with metastore

Latest version **1.0.1** (published 2023-03-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @metastore/react
pnpm add @metastore/react
yarn add @metastore/react
bun add @metastore/react
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-03-19 |
| First published | 2023-03-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 25.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | metastore team |
| Maintainers | santhaug |
| Keywords | metastore, sdk, react, game, integration |

## Links

- npm: https://www.npmjs.com/package/@metastore/react
- Repository: https://github.com/MetastoreOfficial/react-sdk
- Homepage: https://github.com/MetastoreOfficial/
- npm.io page: https://npm.io/package/@metastore/react

## 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

- 1.0.1 (latest) — 2023-03-19
- 1.0.0 — 2023-03-19

## README

# @metastore/react

  The official SDK for integrating react-based browser games with Metastore. 


  <a aria-label="NPM version" href="https://www.npmjs.com/package/@metastore/react">
    <img src="https://img.shields.io/npm/v/@metastore/react.svg?style=for-the-badge&labelColor=000">
  </a>
  <a aria-label="Build condition" href="https://www.npmjs.com/package/@metastore/react">
    <img alt="" src="https://img.shields.io/bundlephobia/min/@metastore/react?color=yellowgreen&style=for-the-badge&labelColor=000">
  </a>
  <a aria-label="License" href="https://github.com/MetastoreOfficial/react-sdk/blob/main/LICENSE">
    <img alt="" src="https://img.shields.io/npm/l/@metastore/react.svg?style=for-the-badge&labelColor=000">
  </a>
  <a aria-label="Join the community on discord" href="https://discord.gg/M4nuhPxHaX" target="_blank" rel="noreferrer">
    <img alt="" src="https://img.shields.io/badge/-join%20the%20community-blueviolet?style=for-the-badge&labelColor=000&logo=discord&logoColor=fff">
  </a>

  
  ## Installation:

```bash
npm i @metastore/react
```

or

```bash
yarn add @metastore/react
```

or

```bash
pnpm add @metastore/react
```

## Usage :

### CloseButton Component

`CloseButton` will close the iframe when clicked. Pass your customized button as its child element, without specifying any `onclick` event.

```js
import React from 'react'
import { CloseButton } from '@metastore/react';


const Options = () => {
  return (
    <div>
        <button>Start Game</button>
        <button>Options</button>
        <CloseButton>
            <p>Close</p>
        </CloseButton>
    </div>
  )
}

export default Options
```

### useMetastoreData Hook

You can utilize the `useMetastoreData` hook to retrieve essential details, including isMetastore, isMobile, and orientation.

- The `data.isMobile` property returns a boolean value indicating whether the user is accessing the website from a mobile device or not.

- The `data.orientation` property returns either "portrait" or "landscape," representing the current orientation of the user's device.

- The `loading` property returns a boolean value indicating whether the data has been successfully fetched or not.

- The `isMetastore` property returns a boolean value indicating whether the website is being displayed within a metastore iframe or not. You can utilize this value to provide dynamic content if you are publishing the game on multiple websites.

```js
import React from 'react'
import { CloseButton, useMetastoreData } from '@metastore/react';


const Options = () => {

    const { data, loading, isMetastore } = useMetastoreData();

    if(loading) return <p>Loading...</p>

    return (
        <div>
            <button>Start Game</button>
            <button>Options</button>
            {isMetastore && (
                <>
                    <CloseButton>
                        <p>Close</p>
                    </CloseButton>
                    <p>Platform: {data?.isMobile}</p>
                    <p>Orientation: {data?.orientation}</p>
                </>
            )}
        </div>
    )
}

export default Options
```

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