{"id":15462959,"url":"https://github.com/philnash/web-share-wrapper","last_synced_at":"2025-06-14T16:05:37.303Z","repository":{"id":49137853,"uuid":"122134711","full_name":"philnash/web-share-wrapper","owner":"philnash","description":"A web component that wraps other share elements to replace with a web share button where supported.","archived":false,"fork":false,"pushed_at":"2023-04-20T16:11:04.000Z","size":81,"stargazers_count":24,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-22T11:18:06.077Z","etag":null,"topics":["web-component","web-components","web-share","web-share-api"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philnash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-19T23:38:00.000Z","updated_at":"2024-08-14T02:15:31.000Z","dependencies_parsed_at":"2024-10-02T00:06:28.818Z","dependency_job_id":"677d1767-b598-4b77-b801-e297cbdd4e2d","html_url":"https://github.com/philnash/web-share-wrapper","commit_stats":{"total_commits":35,"total_committers":4,"mean_commits":8.75,"dds":0.2571428571428571,"last_synced_commit":"ac700b7dd3c0eb6ae8854c52d33f27d06e154595"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/philnash/web-share-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fweb-share-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fweb-share-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fweb-share-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fweb-share-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philnash","download_url":"https://codeload.github.com/philnash/web-share-wrapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fweb-share-wrapper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259843329,"owners_count":22920311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["web-component","web-components","web-share","web-share-api"],"created_at":"2024-10-02T00:06:22.299Z","updated_at":"2025-06-14T16:05:37.276Z","avatar_url":"https://github.com/philnash.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `\u003cweb-share-wrapper\u003e`\n\n[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/philnash/web-share-wrapper)\n\nA custom element that can be used to wrap existing share buttons and replace them with a button that invokes the [Web Share API](https://philna.sh/blog/2017/03/14/the-web-share-api/).\n\nFor example, in supporting browsers the following HTML will show a plain `\u003cbutton\u003e` saying \"Share\". In browsers that don't support the Web Share API, the default link to share on Twitter will be displayed.\n\n```html\n\u003cweb-share-wrapper\u003e\n  \u003ca href=\"https://twitter.com/intent/tweet?text=Share+Text\u0026amp;url=SHARE_URL\"\u003eShare on Twitter\u003c/a\u003e\n\u003c/web-share-wrapper\u003e\n```\n\n## How to use\n\nThe `\u003cweb-share-wrapper\u003e` is a web component that you can use to enhance your website with the Web Share API. If the API is available, the component will replace its contents with a single share button or a template that you provide.\n\nThe component only activates if the Web Share API is available, otherwise it will just show it's contents.\n\n### Browser support\n\nCurrently the only browser that supports the Web Share API (Chrome on Android) also supports custom elements and templates. So this module works where it will work and will fallback to your original HTML where it doesn't.\n\n### Installation\n\n#### Bower\n\nYou can install the component with bower.\n\n```bash\nbower install --save web-share-wrapper\n```\n\n#### npm\n\nYou can also install with npm.\n\n```bash\nnpm install web-share-wrapper\n```\n\nOnce installed, you can either use the minified version by referencing it from the `dist` directory.\n\n```html\n\u003cscript src=\"./node_modules/web-share-wrapper/dist/web-share-wrapper.min.js\"\u003e\u003c/script\u003e\n```\n\nOr if you have a build step, you can require the module.\n\n```javascript\nconst WebShareWrapper = require('web-share-wrapper');\n```\n\n#### unpkg\n\nIf you want to use the component from the unpkg CDN then you can.\n\nYou can get the latest version using the bare URL. See more options on [https://unpkg.com/](https://unpkg.com/).\n\n```html\n\u003cscript src=\"https://unpkg.com/web-share-wrapper\"\u003e\u003c/script\u003e\n```\n\n### Example\n\n```html\n\u003cweb-share-wrapper\u003e\n  \u003ca href=\"https://twitter.com/intent/tweet?text=Share+Text\u0026amp;url=SHARE_URL\"\u003eShare on Twitter\u003c/a\u003e\n\u003c/web-share-wrapper\u003e\n```\n\nIf `navigator.share` is available, the contents of the `\u003cweb-share-wrapper\u003e` will be replaced with a single `\u003cbutton\u003e` element, which when clicked will invoke the Web Share API.\n\nCheck out [this page with more examples](https://philnash.github.io/web-share-wrapper).\n\n### Attributes\n\nYou can set attributes to control the text on the share button and the text and URL that is shared. The available attributes are:\n\n- **text**: Sets the text on the share button.\n- **template**: An id for a `\u003ctemplate\u003e` element. The component will find the template, hydrate it and add it as the child of the component. This overrides the `text` attribute.\n- **sharetitle**: Sets the title to be shared.\n- **sharetext**: Sets the text to be shared. Falls back to the text contents of the `\u003ctitle\u003e` element.\n- **shareurl**: Sets the URL to be shared. Fallsback to the `href` of the canonical link, failing that `window.location.href`.\n\n```html\n\u003cweb-share-wrapper text=\"Share this\" sharetitle=\"This amazing thing was shared\" sharetext=\"You should really click on the link to learn more\" shareurl=\"http://example.com/amazing\"\u003e\n  \u003ca href=\"https://twitter.com/intent/tweet?text=Share+Text\u0026amp;url=SHARE_URL\"\u003eShare on Twitter\u003c/a\u003e\n\u003c/web-share-wrapper\u003e\n```\n\nCheck out [this page with more examples](https://philnash.github.io/web-share-wrapper).\n\n### Events\n\nThe `\u003cweb-share-wrapper\u003e` emits one of two events in response to the result of using `navigator.share`.\n\nIf the share is successful then a `share-success` event is fired. The share title, text and URL are emitted in the `event`'s `details` (though the user may have edited them in the share target).\n\nIf the share is unsuccessful then a `share-failure` event is fired. The share title, text, URL and the error that was thrown are emitted in the `event`'s `details`.\n\n## Tests\n\n[TODO]\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/philnash/web-share-wrapper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct.\n\n## License\n\nThe code is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the `\u003cweb-share-wrapper\u003e` project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/web-share-wrapper/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilnash%2Fweb-share-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilnash%2Fweb-share-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilnash%2Fweb-share-wrapper/lists"}