When developing the Nätklok learning platform for Stöldskyddsföreningen, I got a request from the client to make it easy for users to share the platform on social media. More specifically, since the platform consisted of interactive questions aimed at teaching the user, the client wanted a way to share a specific question.
I started browsing, looked through npm, Github and scoured Medium, but didn’t manage to find a package that uses the latest technology and looks clean and minimalistic at the same time. That’s why I create react-share-on-social, a social share package that uses native sharing if supported, or displays a beautiful fallback if not.
How I built it
- The package uses the Web Share API in the environments that support it. Web Share is a way for a website to invoke the native sharing capabilities of the host platform.
- I also integrated a way for the user to copy the share link to the clipboard with ease. In order for this functionality to be reliable I used the copy-to-clipboard package.
- To not disturb the existing React DOM tree in applications that use the package, I used React Portal.