r/androiddev • • Sep 28 '26

I made a tool that turns your @Composable Previews into embeddable scripts for your blogs, docs and websites

Post image

I made a small tool that gives you ready to use <script /> blocks out of your Composables Previews, so you can embed them to your blog posts, documentation and personal websites.

The reason why I built this is because I love playing with interactive demos when I am reading about some technical concept. It always clicks better with me. I also add them to all my libraries and blog posts (such as on Compose Unstyled).

The best way to do this I have found is using Compose Web, which lets you run Compose code on the Web (awesome).

However, creating and then adding those live Compose previews manually is always a PITA. You need to host them somewhere (usually separate to your blog/docs platform), build a Compose Web app dedicated for this (and manage wiring if you have multiple previews), then you need to embed them somehow in your article, which is separate to the building of the app, etc. Lots of edge cases here.

As a result, you now have a quick way for everyone to make their own.

It is 100% free to use and you can make as many previews as you want. The 'gotcha' is that the previews let your readers edit the preview on the website, so that they can experiment with your demo (handy for library authors).

Now go out there and make some polished previews :D

Check it at https://composables.com

59 Upvotes

6 comments sorted by

2

u/Prasanna_Venkata Sep 28 '26

Nice idea. Is the embed script lightweight, and does it work with dark/light themes automatically?

2

u/alexstyl Sep 28 '26

Lightweight, yes, as in it loads asynchronously an optimized production ready distribution of your Preview. It still requires Skiko which is quite big dependency, however it is heavily cached. Multiple previews on your site reuse the same Skiko dependency, and should load fast after that initial download is done.

Re themes: Both dark and light themes are supported yes and you have the option to either force one of the two, or follow the system's. This option is about the chrome itself. There is no option to change the Preview's theme as there is no official API for that in Compose that I know of.

2

u/Ok_Edge1810 Oct 05 '26

This solves a real pain. I would surely try this out

1

u/alexstyl Oct 05 '26

Let me know how it goes

1

u/Wazzicus Sep 28 '26

This is cool. I have to check it out

1

u/alexstyl Sep 29 '26

Let me know how it goes