Did you know you can create Twitter and Facebook share links using regular HTML?
Both Twitter and Facebook have URLs that you can use to generate a share. The trick is your "Payload" has to be URL encoded so that any special characters don't break the browser link:
Notice the https:// becomes https%3A%2F%2F
One thing to make it even more useful is to ensure you capture any querystring parameters. You know, things like ?page= or #thispart
You can grab those using window.location.search or individually with
const params = new URLSearchParams(window.location.search);