
Building Design Systems That Bridge Designers and Developers
The launch of Onlook on Hacker News this week—a desktop app that lets designers manipulate React components visually while writing actual code—reveals something IT professionals have known for years but rarely solve elegantly: the designer-developer handoff is still brutally inefficient at most companies. Over 25,000 people have already supported this open-source project, and that enthusiastic response points to a persistent pain point in modern web development workflows.
What makes Onlook technically interesting isn’t just another WYSIWYG editor. It’s an entire architecture challenge: how do you build a system that parses live React codebases, provides real-time visual manipulation, and writes changes back to actual component files without breaking your build? Let’s dig into the technical patterns that make this category of tooling possible, because whether you’re evaluating Onlook or building internal developer tools at your organization, understanding these fundamentals will make you a more effective technical decision-maker.
Table of Contents
- AST Manipulation: The Core of Visual Code Editors
- Building Live Preview Systems That Don’t Lie
- Component Inspection and Runtime Analysis
- Practical Implementation: Building a Simple Visual Editor
AST Manipulation: The Core of Visual Code Editors
When you drag a component in a visual editor and expect the underlying JSX to update automatically, you’re dealing with Abstract Syntax Tree (AST) manipulation. This is the same technology that powers ESLint, Prettier, and every code transformation tool you use daily. The difference is scope: instead of linting or formatting, you’re parsing React components, identifying the nodes that correspond to visual elements, and rewriting them based on user interactions.
Tools like Babel provide the parser infrastructure. When Onlook reads your React file, it’s converting JSX into an AST representation where every element, prop, and child becomes a traversable node. The technical challenge is maintaining that mapping bidirectionally—when a designer changes a margin value in the UI, the tool must locate the exact AST node, modify it, and regenerate valid code.
// Using Babel to parse and modify JSX
const babel = require('@babel/core');
const t = require('@babel/types');
const code = ``;
const output = babel.transformSync(code, {
plugins: [{
visitor: {
JSXElement(path) {
// Find the margin attribute and update it
path.node.openingElement.attributes.forEach(attr => {
if (t.isJSXAttribute(attr) && attr.name.name === 'margin') {
attr.value = t.stringLiteral('20px');
}
});
}
}
}]
});
console.log(output.code); // Modified JSX with margin="20px"
This example demonstrates the fundamental operation behind visual editors. You’re not manipulating strings—you’re traversing a syntax tree. Many developers building internal tools miss this distinction and resort to regex-based find-and-replace, which breaks the moment someone uses conditional rendering or spreads props. If you’re serious about tooling in the React ecosystem, understanding AST manipulation is non-negotiable. Platforms like Coursera offer JavaScript compiler courses that cover these patterns in depth, particularly useful for teams building custom development toolchains.
Building Live Preview Systems That Don’t Lie
The second technical pillar is the live preview environment. When Onlook overlays a canvas on your running application, it’s not screenshotting your browser—it’s running your actual development server and injecting instrumentation code that reports back element positions, styles, and component boundaries. This is where things get architecturally interesting.
Electron apps like Onlook embed a Chromium instance, giving them low-level access to the DOM. But the real trick is the communication layer between the visual editor and your running React app. This typically involves a WebSocket connection where the editor sends commands (“select this component”) and the instrumented app responds with structural data (“here are its props, computed styles, and position”).
The technical pattern to understand here is the injection of a runtime inspector. When you start Onlook’s development mode, it’s essentially doing what React DevTools does—injecting a script that hooks into React’s internal Fiber tree. This gives it access to component instances, not just DOM nodes. That’s the difference between a glorified screenshot tool and something that understands your component architecture.
// Simplified runtime inspector injection
window.__ONLOOK_INSPECTOR__ = {
getComponentAtPoint: (x, y) => {
const element = document.elementFromPoint(x, y);
// Walk up the DOM tree to find the React Fiber node
const fiberKey = Object.keys(element).find(key =>
key.startsWith('__reactFiber')
);
if (fiberKey) {
const fiber = element[fiberKey];
return {
name: fiber.type.name || fiber.type,
props: fiber.memoizedProps,
file: fiber._debugSource?.fileName
};
}
return null;
}
};
// Usage from the editor UI
const component = window.__ONLOOK_INSPECTOR__.getComponentAtPoint(150, 300);
console.log(component); // {name: 'Button', props: {...}, file: 'src/Button.jsx'}
This inspector pattern is what separates amateur visual editors from professional-grade tools. You need programmatic access to React’s internals to build meaningful designer experiences. For teams wanting to deepen their understanding of React’s architecture and build internal tooling, DataCamp provides hands-on courses covering React internals and advanced component patterns that directly apply to this problem space.
Handling Hot Module Replacement
One complexity that catches many tool builders: your visual editor needs to play nicely with HMR (Hot Module Replacement). When a developer manually edits code in their IDE while the visual editor is open, both systems are trying to reload components. The solution requires coordination—typically through shared state in the development server and careful debouncing of file system events. Watch for race conditions where the visual editor writes a change, HMR triggers a reload, and the editor receives its own change as an external update.
Component Inspection and Runtime Analysis
The third technical layer is understanding what can and cannot be edited visually. Not all React code is created equal from a visual editing perspective. Hardcoded JSX in a component file? Easy to manipulate. Props passed down from a parent? You need to traverse up the component tree. Conditionally rendered elements? Now you’re dealing with branching logic that changes based on state.
Smart visual editors establish boundaries. Onlook focuses on styling and layout—properties that can be safely modified without understanding business logic. When you change a component’s width, you’re modifying either an inline style or a className prop, both of which are straightforward AST operations. But when someone wants to change whether a button is disabled based on form validation, you’ve crossed into logic territory that requires human judgment.
Practical Implementation: Building a Simple Visual Editor
Let’s bring this together with a practical example. Say you want to build a minimal visual editor for your team’s component library. You don’t need Onlook’s full feature set—just the ability to preview components and tweak basic props. Here’s the architectural skeleton:
First, you need a component registry that catalogs what’s available to edit. This is typically a build step that crawls your component directories and extracts prop types using TypeScript’s compiler API or React’s prop-types. Each component gets metadata: name, file path, editable props, and default values.
Second, you need the preview environment—a simple Next.js or Vite app that can render any component from your registry dynamically. This receives commands from your editor UI via WebSocket or HTTP.
Third, the actual editor UI: a sidebar with controls for each prop, a canvas showing the live preview, and a code panel showing the generated JSX. When someone adjusts a slider for padding, you update the preview in real-time and regenerate the JSX code.
The file writing step—actually modifying component files—requires the AST manipulation we covered earlier. You parse the target file, locate the component, modify the appropriate props or styles, and write it back. For production tools, you’ll want to add git integration, undo/redo stacks, and conflict resolution when multiple people edit simultaneously.
The File System Integration Challenge
One often-overlooked aspect: file system permissions and cross-platform compatibility. Desktop apps like Onlook use Electron’s Node.js integration to read and write files directly, but web-based tools face browser security restrictions. If you’re building a web-based visual editor, you’ll need either a backend service with file system access or new browser APIs like the File System Access API (which still has limited support). This architectural choice—desktop vs. web—fundamentally shapes what’s technically feasible.
What makes the Onlook launch particularly relevant for IT professionals isn’t just another tool to evaluate—it’s validation that the market desperately wants better designer-developer workflows, and that creates opportunities. Whether you’re building internal tooling at your company, evaluating third-party solutions, or positioning yourself as an expert in developer experience, understanding the technical architecture behind visual code editors gives you a substantial advantage. These aren’t trivial problems to solve, which is exactly why companies fund startups like Onlook and why senior engineers who can architect these systems command premium compensation.
The pattern holds across the industry: the best developer tools understand both the human workflow problem and the deep technical implementation required to solve it properly. AST manipulation, runtime inspection, and bidirectional code synchronization aren’t just academic exercises—they’re the difference between a demo that impresses on Twitter and a tool teams actually adopt in production. As you evaluate tools or build your own, keep asking: does this modify actual code or just generate it? Does it understand my component architecture or just the DOM? Can it handle real-world complexity like conditional rendering and dynamic props? Those questions reveal whether you’re dealing with a mature solution or clever vaporware.
Master React Internals and Tooling
Learn the AST manipulation, component inspection, and architecture patterns that power visual code editors like Onlook. Build the developer tools your team actually needs.