Embed Runkit widget in Discourse

AI-generated summary

In a support discussion titled “Embed Runkit widget in Discourse,” spalladino asked if embedding a Runkit widget is possible on their Discourse-hosted instance (business plan). sam confirmed it’s technically feasible via a theme component that decorates posts, but warned about potential risks: violating CSP, slowing down Discourse with heavy JS, and trusting Runkit’s code execution. They estimated 1–2 days of development and suggested the Marketplace for hiring help. Falco offered a simpler solution: adding https://runkit.com/ to the allowed iframes setting enables automatic oEmbed rendering — just paste the Runkit URL on its own line. They noted layout issues with long embeds and suggested a theme component for better handling. spalladino thanked both, clarified that Runkit runs code server-side (making it safer, though potentially slower), and confirmed the allowed iframes fix worked perfectly — they’ll consider building a theme component for improved UX.

Hey there! I’m running a Discourse-hosted Discourse instance (business plan, not enterprise), and wanted to embed a Runkit widget in a post. Do you know whether this is possible? Thanks!

Technically this is possible with a theme component that decorates posts, you would then define a [wrap] section for the embed and on post decoration load up the library and do the embedding stuff.

I would recommend quite a bit of caution here:

  1. You don’t want to invalidate your CSP, so you would have to consider this
  2. You do not want to slow down Discourse due to loading some big dynamic JS payload
  3. You are placing a lot of trust with runkit by allowing them to run JavaScript on your Discourse.

I would estimate building something here would take 1-2 days of work. If you have budget perhaps open a topic on Marketplace ? Theme components can be installed fine on our business plan setups.

Thanks to the oEmbed standard, you can add https://runkit.com/ to the setting allowed iframes and call it a day.

Just paste a runkit URL in a line by itself and Discourse will work it’s magic:

https://runkit.com/falco/5e13a3b7f5d2e2001a5741d2

becomes

https://runkit.com/falco/5e13a3b7f5d2e2001a5741d2

It does becomes weird when the embed is too long, so a theme-component to help decorate (and scroll) embeds may be needed indeed.

Thanks a lot for your replies! @sam Runkit runs code server-side on their end, not client-side, so it’s rather safe (it may slow down loading due to the loading of the widget itself, but that’s it).

@Falco I had totally missed the allowed iframes setting. As soon as I set it, it started working like a charm! I’ll see what I can do regarding the team component :slight_smile: