4
5 Comments

3rd party scripts in a SPA

Here is a problem I come across all the time. I'm really curious if I'm alone on this. I want to use this awesome 3rd party tool in my Vue/React application. Maybe it's a simple Typeform, or a Wistia Video, Analytic tracking etc.. etc... The installation instructions are always super simple "just copy and paste our JS snippet into your html".

If you have a SPA, copying and pasting their snippet will not work. Usually this problem is solved by using a specific Vue/React/Angular library, but often these libraries don't exist. When this happens, the simple 30 second integration can turn into an all day project.

I'm really curious how others are solving this problem?

I feel like there is an opportunity here.

posted to Icon for group Developers
Developers
on March 2, 2020
  1. 2

    I ran into this problem adding a ConvertKit form to a Vuejs SPA. In that case they provided an html blob as an option, so I was able to pull that apart into a component, but it certainly wasn't just a copy and paste.

  2. 1

    I use Next.js, so in my document, I add a script tag with the snippet set using dangerouslySetInnerHtml. Seems to work pretty well.

  3. 1

    I have ran into this issue several times when integrating ad scripts. I usually have to write a custom component unless it's a popular system like adsense and the community has an existing solution.

  4. 1

    Have you tried dangerouslysetinnerhtml or wrapping in <script></script> tags? https://reactjs.org/docs/dom-elements.html

  5. 1

    Usually, many third-party libraries have a version of the npm package. It easily connects to any component and used. If you have a library that you need to connect, I can prepare an example of integration, on it you can work with other libraries.

  6. 1

    This comment was deleted a month ago.

Trending on Indie Hackers
I shipped a productivity SaaS in 30 days as a solo dev — here's what AI actually changed (and what it didn't) User Avatar 256 comments Never hire an SEO Agency for your Saas Startup User Avatar 107 comments A simple way to keep AI automations from making bad decisions User Avatar 71 comments 85% of visitors leave our pricing page without buying. sharing our raw funnel data User Avatar 39 comments Are indie makers actually bad customers? User Avatar 39 comments We automated our business vetting with OpenClaw User Avatar 38 comments