Create embeddable widget with turbo

Hello,

Wondering whether anybody has created an embeddable widget (something similar to Embed the Zendesk Web Widget) for users to put inside their own websites using turbo/stimulus. Specifically, requiring multiple pages inside the “widget”.

Obvious approach I think is to use an iframe to embed our “site” inside the users site. Is using a web component wrapper a possible alternative?

Is there some other way of doing this?

Thanks,
Mark

There is an article scheduled on the Rails Designer site scheduled in a couple of weeks from now. It essentially the basics from the included code/repo of the embeddable widget of the book JavaScript for Rails Developers (it shows how to build a basic live chat widget using ActionCable with some vite/rollup niceties).

I’ve built a few in the past and also recently for clients.

iframe is typically the easiest to implement; no tricky cascading and everything is scoped. Web components or custom elements could be a solution too. Shadow dom could be used too.

You could use Stimulus by injecting a script element if it is undefined on window. But that seems a bit much for something fairly simple as the zendesk widget.

Thanks for that.

The ZenDesk was just an example of an embeddable widget. The actual thing will contain many “pages” so ideally I want to stay in the turbo paradigm.

OP stated

So what are you asking?