# react-mweb-share

> A small package developed on top of mobile's built-in share api (See [Web share api](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share)). It has support for both sync share operations (when the url is known already), as well as async (e.g.

Latest version **0.1.5** (published 2023-10-27) · 0 weekly downloads

## Install

```sh
npm install react-mweb-share
pnpm add react-mweb-share
yarn add react-mweb-share
bun add react-mweb-share
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2023-10-27 |
| First published | 2023-10-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | radu2147 |
| Keywords | typescript, Reactjs, Next.js, react-web-share, react-mweb-share, react-share-mobile, react-mobile-share, mobile-share, share |

## Links

- npm: https://www.npmjs.com/package/react-mweb-share
- Repository: https://github.com/radu2147/react-mobile-share
- Homepage: https://github.com/radu2147/react-mobile-share#readme
- Issues: https://github.com/radu2147/react-mobile-share/issues
- npm.io page: https://npm.io/package/react-mweb-share

## Dependencies (8)

- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [typescript](https://npm.io/package/typescript.md) ^4.9.5
- [web-vitals](https://npm.io/package/web-vitals.md) ^2.1.4
- [@types/node](https://npm.io/package/@types/node.md) ^16.18.58
- [@types/react](https://npm.io/package/@types/react.md) ^18.2.28
- [react-scripts](https://npm.io/package/react-scripts.md) 5.0.1
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^18.2.13

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2023-10-27
- 0.1.4 — 2023-10-25
- 0.1.2 — 2023-10-25
- 0.1.1 — 2023-10-25
- 0.1.0 — 2023-10-24

## README

## react-mobile-share ![Checks](https://github.com/radu2147/react-mobile-share/actions/workflows/checks.yml/badge.svg)

A small package developed on top of mobile's built-in share api (See [Web share api](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share)). It has support for both sync share operations (when the url is known already), as well as async (e.g. to be used for shortlink generation)
### Features

- [X] Full behaviour customization
- [X] Sync share support wrapper component
- [X] Sync share support hook
- [X] Async share support wrapper component
- [X] Async share support hook
- [ ] Support for images

### Install

```
npm i -D react-mweb-share
yarn add -D react-mweb-share
```

### Examples
Sync version:

```
import * as React from 'react';
import { useMobileShare } from 'react-mweb-share';

const Button = ({url}: {url: string}) => {
    const { share } = useMobileShare({url, title: "Howdy"});
    return (
        <button onClick={share}>
            Share!
        </button>
    );
}
```

Async version:

```
import * as React from 'react';
import { useMobileShareAsync } from 'react-mweb-share';

const Button = () => {
    const generateURL = new Promise((res) => res({url: "https://radu2147.github.io"}));
    const { share, loading } = useMobileShareAsync({generateURL, title: "Howdy"});
    if(loading){
        return <p>Loading...</p>
    }
    return (
        <button onClick={share}>
            Share!
        </button>
    );
}
```

Wrapper component:

```
import * as React from 'react';
import { MobileShareWrapper } from 'react-mweb-share';

const Button = ({url}: {url: string}) => {
    return (
        <MobileShareWrapper url={url} title={"Howdy"}>
            <button onClick={share}>
                Share!
            </button>
        </MobileShareWrapper>
    );
}
```

Async wrapper component:

```
import * as React from 'react';
import { MobileShareAsyncWrapper } from 'react-mweb-share';

const Button = () => {
    const generateURL = new Promise((res) => res({url: "https://radu2147.github.io"}));
    const [showDialog, setShowDialog] = React.useState(false);
    return (
        <>
            <MobileShareAsyncWrapper generateURL={generateURL} title={"Howdy"} onLoad={() => setShowDialog(true)} onSuccess={() => setShowDialog(false)}>
                <button onClick={share}>
                    Share!
                </button>
            </MobileShareAsyncWrapper>
            <Dialog visible={showDialog} toggleDialog={() => setShowDialog(!showDialog)}/>
        </>
    );
}
```

### License
[MIT](LICENSE)

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