Live data from Hacker News

Show HN: An open-source, local-first Webflow for your own app

github.com

1–10 of 53 posts

Show HN: An open-source, local-first Webflow for your own app

#1
Hey HN, I’m Kiet, and I’m one of the co-founders of Onlook – an open-sourced desktop app that lets you visually edit your locally running React app, then write your changes back to code in real time.

I posted the repo a few months ago [1] when it was just 2 weeks old. Since then, we’ve made some big changes/improvements. I wanted to share some of the updates we’ve made and add more technical details. Here are the three big ones:

• Inserting new elements - Draw elements in the live page like a design tool and write them back to code. • Component detection - Detect when an element is a re-used component and find its usages. • DOM tree representation - A layers panel similar to the Chrome devtool or Figma.

Technical details [2]:

Visual editing - Onlook is technically a browser that points to your localhost running the app. It can manipulate the DOM like a Chrome Devtool, and all these changes are injected into the page through a CSS stylesheet or DOM manipulation. The changes are non-persistent until written to code.

Write to code - To translate the changes to code, we inject an attribute into the DOM elements at build-time that points back to the code like a source map. The attribute gives us the location of the code block, and the component scope [3]. We then find the code, parse it into an AST, inject the styles, and write it back.

Framework support - This technique is framework agnostic as we can swap in a different compiler for another framework [4]. It can work for any codebase as we’re just using open standards that don’t require any custom code. The code generated is written directly into your codebase, locally, so you can always take the output without being locked-in to the tool.

Actions - All the changes made are stored as actions. This allows them to be serialized, stored, and reproduced. We did it this way so eventually, we can introduce online collaboration or let an agent generate actions. To do this, we’d just need to serve the locally running page and resolve incoming actions.

What’s next?

It’s still a bit bare-bones but the support and suggestions from the HN and open-source communities have helped us a lot with our direction. Now that we’ve built the core engine, we can start doing some cooler visual builder features, fulfilling the “Webflow” part of our mission such as [5]:

• Detecting CSS variables in the page and letting you use them as “design tokens” in the UI. • Duplicating a page and A/B testing designs before committing to code. • Creating new components directly in the canvas. • Creating a front-end project from scratch using Onlook.

Some things we’re considering, but aren’t sure about yet:

• Offer hosting directly from the app. • Collaboration such as real-time edits, comments, and share page as a prototype.

I’d love to hear your thoughts/feedback. This project continues to be a blast to work on and the community response has been awesome. Thank you to everyone who has tried out and contributed to the repo :)

_________

[1] https://news.ycombinator.com/item?id=40904862

[2] https://github.com/onlook-dev/onlook/wiki/Architecture

[3] The attribute looks something like this:

  data-onlook-id="eJxNjUEKwzAMBP+ic6gOKT3k2i+kDzC2aEwcKVgyDQT/vU5pS067sMvMDl6WVZjYYIC7y2GMlgg6IA6je8LAJaUOVmdTO+BDKSvOkWwSfEme1+Q8oXASmVGthCgYaBFFps3wT1csEX3jX0y3hldz2T6C/VAd4SWVhWG4dpAiUyt9/R7Pc/+b+1ut9Q33rUM5"
And decodes to this:

  {"component":"Dashboard","endTag":{"end":{"column":10,"line":620},"start":{"column":5,"line":620}},"path":"/Users/kietho/workplace/onlook/studio/demos/next/components/dashboard.tsx","startTag":{"end":{"column":67,"line":69},"start":{"column":5,"line":69}}}
[4] We’re only supporting a few versions of React at the moment for early focus: https://github.com/onlook-dev/onlook/tree/main/demos

[5] https://github.com/onlook-dev/onlook/wiki/Roadmap

Show HN: An open-source, local-first Webflow for your own app
github.com

Re: Show HN: An open-source, local-first Webflow for your own app

#2
Hey HN! I’m Daniel, the designer on Onlook.

Kiet and I started working together in January to try to solve the design / dev handoff, and we think that this is a great first step to getting more people into code. People have mentioned that Onlook is a great complement to building frontends with Cursor, so if you’re just learning to code with Cursor, try running your projects locally with Onlook.

One thing I’d like to do is open-source our design system and make it easier for designers to contribute. If you have any suggestions or examples of projects that have done this well, let me know!

I’m hopeful that with the help of so many great contributors, we can make an editor experience that doesn’t compromise on the design / code experience!

Re: Show HN: An open-source, local-first Webflow for your own app

#5
post #4

Love it. Just the other day I have been looking for something like this. What preconditions must be met to use this with an existing app? What tech stack is supported (e.g. only Typescript and React and ...)?

We work best for React (js/ts) and TailwindCSS. In-code UI libs like ShadCN also customizes better. Thanks for checking it out :)

Re: Show HN: An open-source, local-first Webflow for your own app

#7
post #4

Love it. Just the other day I have been looking for something like this. What preconditions must be met to use this with an existing app? What tech stack is supported (e.g. only Typescript and React and ...)?

The docs say it's framework-agnostic. I assume then that the editor would only be used for editing css, not html, but I'm sure the founder can correct me if I'm wrong.

I'm also curious how they determine where in source the code needs to change, because you could have (a) external stylesheets, (b) a stylesheet in the html head, (c) tailwind classes, (d) some css-in-js variant, or even (e) direct style application of dom elements in your javascript.

Re: Show HN: An open-source, local-first Webflow for your own app

#8
I love the idea. I'm working on something in the same general category, but a very different approach and I love seeing how others are tackling this problem. Over time I suspect we'll see more tools that attempt to bridge design tools with dev tools - every time I crack open Chrome's inspector, all I can think about is how amazing it could be if it was intended to be used by design teams.

Re: Show HN: An open-source, local-first Webflow for your own app

#9
post #4

Love it. Just the other day I have been looking for something like this. What preconditions must be met to use this with an existing app? What tech stack is supported (e.g. only Typescript and React and ...)?

The docs say it's framework-agnostic. I assume then that the editor would only be used for editing css, not html, but I'm sure the founder can correct me if I'm wrong. I'm also curious how they determine where in source the code needs to change, because you could have (a) external stylesheets, (b) a stylesheet in the html head, (c) tailwind classes, (d) some css-in-js variant, or even (e) direct style application of…

yes, indeed, that's is also what I am curious about

Re: Show HN: An open-source, local-first Webflow for your own app

#10
post #4

Love it. Just the other day I have been looking for something like this. What preconditions must be met to use this with an existing app? What tech stack is supported (e.g. only Typescript and React and ...)?

The docs say it's framework-agnostic. I assume then that the editor would only be used for editing css, not html, but I'm sure the founder can correct me if I'm wrong. I'm also curious how they determine where in source the code needs to change, because you could have (a) external stylesheets, (b) a stylesheet in the html head, (c) tailwind classes, (d) some css-in-js variant, or even (e) direct style application of…

> I assume then that the editor would only be used for editing css, not html

It does edit html. Inserting html elements in this case.

> I'm also curious how they determine where in source the code needs to change

Right now we're editing inline-tailwind because it's the easiest option. It only edits the existing tailwind styles so there could be some interaction with existing styles that have higher-priotity.

The plan later is to have users configure how they want their styles written. We have full code access to be able to edit css stylesheets or inject our own.

Post reply on HN