Lightweight Social Share Buttons

in #stemgeekslast month

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:!%20via%20%40retrogamecoders&

Notice the https:// becomes https%3A%2F%2F

JavaScript has an EncodeURI function built right in, or you can obviously generate the link at development time :)

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 or individually with

const params = new URLSearchParams(;

Its a really simple but interesting tutorial on creating share buttons using simple html tricks. Thanks for this