Facebook/Twitter share implementation?

Hi guys! I've never had to do this before, and I'm wondering if maybe someone had an example of implementing Facebook and/or Twitter Share systems in a solidjs app? I have a "base" I can sort of duplicate but it's an overengineered reactjs code thing and I would much rather do something that's as clean and simple as possible. Is it really necessary to dynamically inject the javascript and such into the <head> for all this to work? I'd love some guidance!
10 Replies
fabiospampinato
fabiospampinato•2y ago
If I remember correctly you probably can just point the user to facebook.com/share?myUrl=... or something like that, so a couple of buttons for sharing on social networks might require very little code. I haven't looked at this in a long time time.
<Alterion.Dev>
<Alterion.Dev>•2y ago
yeah it might be that https://gist.github.com/eslachance/71d34735b072537dcda1e94259f27aa7 was legitimately overengineered by the person writing that code (this is from an existing codebase, not just a random thing I found online, so it's worse 😛 )
fabiospampinato
fabiospampinato•2y ago
Definitely, no way you need to download Facebook's SDK for this stuff
<Alterion.Dev>
<Alterion.Dev>•2y ago
alright let me try to integrate this with the simplest code I can and we'll see. one of these shares is done with an image from an external screenshotting system so maybe there's a hidden requirement but we'll see!
lxsmnsyc
lxsmnsyc•2y ago
Web Share API was the simplest (and works best on the majority of devices) but I could probably port this to SolidJS https://www.npmjs.com/package/react-share
Alex Lohr
Alex Lohr•2y ago
GitHub
solid-primitives/packages/share at main · solidjs-community/solid-p...
A library of high-quality primitives that extend SolidJS reactivity. - solid-primitives/packages/share at main · solidjs-community/solid-primitives
<Alterion.Dev>
<Alterion.Dev>•2y ago
😅 I missed this reply earlier but thank you very much, I really should pay a whole lot more attention to react-primitives, I swear to god half the code I write is probably already a helper here! Seems to work flawlessly!
Alex Lohr
Alex Lohr•2y ago
React-primitives? 🤣
<Alterion.Dev>
<Alterion.Dev>•2y ago
My brain... really really really has trouble letting go of react <:sp_cringe:862089564776431646>
Alex Lohr
Alex Lohr•2y ago
Same here, but for Solid.js, which makes it harder to react to react 🙂
Want results from more Discord servers?
Add your server