https://github.com/hc-oss/react-web-share
Tiny web share wrapper with fallback for unsupported browsers
https://github.com/hc-oss/react-web-share
api fallback hacktoberfest lightweight react share tiny web
Last synced: 3 months ago
JSON representation
Tiny web share wrapper with fallback for unsupported browsers
- Host: GitHub
- URL: https://github.com/hc-oss/react-web-share
- Owner: hc-oss
- License: mit
- Created: 2020-04-29T20:44:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T10:02:23.000Z (over 1 year ago)
- Last Synced: 2025-03-31T10:09:42.608Z (4 months ago)
- Topics: api, fallback, hacktoberfest, lightweight, react, share, tiny, web
- Language: TypeScript
- Homepage: https://codesandbox.io/s/react-web-share-46skt
- Size: 1.71 MB
- Stars: 64
- Watchers: 1
- Forks: 35
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# react-web-share
Tiny [Web Share API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) wrapper with fallback for unsupported browsers
[](https://github.com/hc-oss/react-web-share/actions)
[](https://npm.im/react-web-share)
[](https://bundlephobia.com/result?p=react-web-share@latest)[](https://codesandbox.io/s/react-web-share-46skt)
> 💡 most browsers restricts web share api only to https websites
## ✨ Features
- 🍃 Only ~6kb gzipped and no external dependencies
- 🌀 Uses React Portal
- ✌ Written w/ TypeScript## 🔧 Installation
```bash
npm i react-web-share # npm
yarn add react-web-share # yarn
```## Preview
### Mobile

### Desktop

## 📦 Example
```tsx
import React, { useState } from "react";
import { RWebShare } from "react-web-share";const Example = () => {
return (
console.log("shared successfully!")}
>
Share 🔗
);
};export default Example;
```## 👀 Props
| Prop | Description | Type | Default |
| --------------- | --------------------------- | -------------------- | --------------------------------------------- |
| `data` | Share Object | `{text, url, title}` | `{text: "", url: currentURL, title: "Share"}` |
| `sites` | sites | `string[]` | all platforms (see list below for key list) |
| `closeText` | translate close | `string` | localise close text |
| `onClick` | callback on sucessful share | | |
| `disableNative` | disables native share | `boolean` | `false` |## 🌎 Sites
- telegram
- copy (Copy to Clipboard)
- vk
- okru## 📜 License
MIT © [harshzalavadiya](https://github.com/harshzalavadiya)