All Projects → on2-dev → Share Api Polyfill

on2-dev / Share Api Polyfill

Licence: mit
A polyfill for the sharing that can be used in desktop too, so your users can shere in their twitter, facebook, messenger, linkedin, sms, e-mail, print, telegram or whatsapp.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Share Api Polyfill

webviewhs
🌐 A Haskell binding to the webview library created by Serge Zaitsev.
Stars: ✭ 109 (-48.1%)
Mutual labels:  native, desktop, webapp
Lazy
Kule Lazy4 / CSS Framework
Stars: ✭ 147 (-30%)
Mutual labels:  mobile, desktop
Canoe
Canoe is a Nano Wallet heavily based on the MIT licensed Copay wallet from Bitpay
Stars: ✭ 146 (-30.48%)
Mutual labels:  mobile, desktop
Picodeploy
Deploy Pico-8 Carts as Standalone Applications on Desktop 🖥️(Electron) and Mobile 📱(Ionic) 📦👾
Stars: ✭ 153 (-27.14%)
Mutual labels:  mobile, desktop
Expo
An open-source platform for making universal native apps with React. Expo runs on Android, iOS, and the web.
Stars: ✭ 15,550 (+7304.76%)
Mutual labels:  mobile, native
Proton Native
A React environment for cross platform desktop apps
Stars: ✭ 10,834 (+5059.05%)
Mutual labels:  desktop, native
Vue Fullpage
a single page scroll plugin for [email protected] https://river-lee.github.io/vue-fullpage/examples/
Stars: ✭ 148 (-29.52%)
Mutual labels:  mobile, desktop
Coronavirus Tracker Api
🦠 A simple and fast (< 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. It's written in python using the 🔥 FastAPI framework. Supports multiple sources!
Stars: ✭ 1,577 (+650.95%)
Mutual labels:  api, webapp
Robot Js
Native system automation for node.js
Stars: ✭ 169 (-19.52%)
Mutual labels:  desktop, native
Robot
Native cross-platform system automation
Stars: ✭ 178 (-15.24%)
Mutual labels:  desktop, native
Youi
Next generation user interface and application development in Scala and Scala.js for web, mobile, and desktop.
Stars: ✭ 186 (-11.43%)
Mutual labels:  mobile, desktop
React Nodegui Starter
Starter repository for react based native desktop apps using react-nodegui
Stars: ✭ 132 (-37.14%)
Mutual labels:  desktop, native
Tooty
An alternative multi-accounts Web client for Mastodon.
Stars: ✭ 124 (-40.95%)
Mutual labels:  api, webapp
Conari
🧬 Platform for unmanaged memory, pe-modules, related PInvoke features, and more for: Libraries, Executable Modules, enjoy using of the unmanaged native C/C++ in .NET world, and other raw binary data …
Stars: ✭ 138 (-34.29%)
Mutual labels:  api, native
Fenix
A simple and visual static web server with collaboration features.
Stars: ✭ 1,559 (+642.38%)
Mutual labels:  share, desktop
Alize
Visualize Your Github Profile
Stars: ✭ 148 (-29.52%)
Mutual labels:  api, webapp
Device Detector Js
A precise user agent parser and device detector written in TypeScript
Stars: ✭ 193 (-8.1%)
Mutual labels:  mobile, desktop
Traduora
Ever® Traduora - Open-Source Translation Management Platform
Stars: ✭ 1,580 (+652.38%)
Mutual labels:  api, webapp
Swiftlysalesforce
The swiftest way to build iOS apps that connect to Salesforce
Stars: ✭ 115 (-45.24%)
Mutual labels:  api, mobile
Texture Compressor
CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container.
Stars: ✭ 156 (-25.71%)
Mutual labels:  mobile, desktop

Share API Polyfill

This is a (6kb) polyfill for the Web Share API that can be used in desktop too, so your users can share in their twitter, facebook, messenger, linkedin, sms, e-mail, print, telegram or whatsapp.

It also supports multilanguage (see the list of languages and you can help us with that :) ).

This is a very simple, single file import polyfill.

JavaScript Share API Polyfill in a Browser
see the share api polyfill in action

Installing it:

Just import it like so:

<script src="https://unpkg.com/share-api-polyfill/dist/share-min.js"></script>

Note that we are using the unpkg cdn to load it, you could also save it in your own structure so you can cache it with service workers and have it "close" to your own domain.

You can also install it using npm:

npm install share-api-polyfill --save
# or
yarn add share-api-polyfill

Now, it will use the native share panel if it is available (only available on mobile devices) and, if not, it will enable an HTML structure in your page showing options for your users.

Here, check this demo and see the share api polyfill in action.

The Share API

The oficial share api works like this:

navigator.share({
  title: 'Web Share API Polyfill',
  text: 'A polyfill for the Share API. Use it to share in both desktops and mobile devices.',
  url: location.href
})
.then( _ => console.log('Yay, you shared it :)'))
.catch( error => console.log('Oh noh! You couldn\'t share it! :\'(\n', error));

But in this case, you can also pass your Facebook App Id to enable sharing with messenger. Also, you can pass in a list of hashtags to be used when sharing with twitter.

navigator.share({
  title: 'Web Share API Polyfill',
  text: 'A polyfill for the Share API. Use it to share in both desktops and mobile devices.',
  url: location.href,

  // extra, optional options
  fbId: '123456789123456',
  hashtags: ['javascript', 'shareAPI', 'Polyfill']
})
.then( _ => console.log('Yay, you shared it :)'))
.catch( error => console.log('Oh noh! You couldn\'t share it! :\'(\n', error));

You can pass the hashtags as a single (comma separated) string, or as an array.

Multi language

It will try and use the supported languages based on user's browser language configuration.
If the language is not found, it will uses a fallback (default english).

Currently supported languages:

  • cs
  • de
  • da
  • en
  • es
  • fr
  • ja
  • ko
  • nl
  • ta
  • pl
  • pt
  • ru
  • sv
  • sk
  • tr
  • zh

Feel free to contribute with more languages sending Pull Requests for them :)

Turning features off, in Desktop

You can disable some of the social buttons from the tool by passing a second object as argument.
As your mobile device will probably have native support for the share API, it will be ignored, being applied only for desktops.

Example:

navigator.share({
    title: 'Web Share API Polyfill',
    text: 'A polyfill for the Share API. Use it to share in both desktops and mobile devices.',
    url: location.href,

    fbId: '123456789123456',
    hashtags: 'javascript,shareAPI,polyfill'
  },
  {
    // change this configurations to hide specific unnecessary icons
    copy: true,
    email: true,
    print: true,
    sms: true,
    messenger: true,
    facebook: true,
    whatsapp: true,
    twitter: true,
    linkedin: true,
    telegram: true,
    skype: true,
    language: 'pt' // specify the default language
  }
)
  .then( _ => console.log('Yay, you shared it :)'))
  .catch( error => console.log('Oh noh! You couldn\'t share it! :\'(\n', error));

If you disable Skype, it will no longer load Skype's SDK, what might be something you want, in case you would like to improve the privacy in your project, avoiding loading third party libraries.

It's open source

Yup, it's open source and you can contribute to it :)

Please refer to our CONTRIBUTING.md and help us improve this tool.

To re-build id, just install the dependencies:

npm install

And build it with gulp

npm run build

And try it locally

npm run demo

Also, if you need to change the icons, they are SVGs located on the share.js script. You will find the oridinal vector (.svg) in the src/icons directory in case you want to change it and copy the svg code.

Donate ❤️

Buy us a coffee :)

BTC: 1GuTME1bGbk7hY7ssrUBh3M1k4AeyVCSjW
ETH: 0x49f1612d4a8e9165f2eb94be79af9dbbf3815af5

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].