Discovering Valdi: A Powerful Cross-Platform UI Framework for Modern Developers
In the ever-evolving world of software development, finding the right tools to build efficient, high-performance applications can make all the difference. If you’re a developer looking to create seamless user interfaces across multiple platforms without compromising on speed or native feel, Valdi might just be the framework you’ve been searching for. As a cross-platform UI framework, Valdi allows you to write declarative TypeScript code once and compile it directly into native views on iOS, Android, and macOS. No web views, no clunky JavaScript bridges—just pure, optimized performance that’s been battle-tested in production environments for years.
Valdi isn’t a newcomer to the scene; it’s been powering significant parts of Snap’s apps for the past eight years. Now in its beta phase as an open-source project, the focus is on refining tools and documentation for broader community use. But don’t let the beta tag fool you—the core technology is robust and ready for real-world applications. In this post, we’ll dive deep into what Valdi is, why it stands out, how to get started, and ways you can contribute to its growth. Whether you’re a seasoned engineer or just graduating with a degree in computer science, this guide will break things down in straightforward terms, helping you understand if Valdi fits your next project.
What Is Valdi and How Does It Work?
At its heart, Valdi is designed to tackle a common pain point in cross-platform development: the trade-off between developer productivity and runtime efficiency. Traditional approaches often force you to choose between quick prototyping with web-based tools (which can feel sluggish on mobile) or diving into platform-specific code (which slows down iteration). Valdi bridges this gap by letting you define UI components in TypeScript using a declarative syntax similar to TSX. These components then compile straight to native views, ensuring your app runs as smoothly as if it were built entirely in Swift for iOS or Kotlin for Android.
Let’s look at a simple example to illustrate. Imagine you want to create a basic “Hello World” component. Here’s how it might look in Valdi:
import { Component } from 'valdi_core/src/Component';
class HelloWorld extends Component {
onRender() {
const message = 'Hello World! 👻';
<view backgroundColor='#FFFC00' padding={30}>
<label color='black' value={message} />
</view>;
}
}
This code renders a view with a yellow background and a black label displaying the message. When run on iOS, it appears as a native element, complete with the performance you’d expect from platform-specific code. You can see a screenshot of it in action below:
What makes this powerful is the underlying compilation process. Valdi doesn’t interpret your code at runtime; it transforms it into optimized native structures. This includes features like automatic view recycling, where a global pool reuses views across screens to minimize creation overhead. Components render independently, avoiding unnecessary parent re-renders, and the layout engine—written in C++—operates efficiently on the main thread with low marshalling costs. Plus, viewport-aware rendering ensures only visible elements are inflated, making it ideal for dynamic lists or infinite scrolling.
For developers coming from frameworks like React Native or Flutter, Valdi’s syntax will feel familiar, but its native compilation sets it apart. It supports TypeScript 5.x for strong typing, and the entire setup integrates with tools like Bazel for reliable builds. If you’re building apps that demand high responsiveness, such as social media features or real-time interactions, Valdi’s architecture can handle it without breaking a sweat.
Key Benefits of Using Valdi in Your Projects
Why choose Valdi over other cross-platform solutions? Let’s break it down into practical advantages that address real developer challenges.
First, native performance without compromises. Many frameworks rely on intermediaries that introduce latency, but Valdi compiles directly to platform views. This means faster load times, smoother animations, and better battery life for users. Features like the optimized layout engine and worker threads for background tasks keep your app responsive even under heavy loads.
Second, accelerated development workflow. Gone are the days of lengthy compile-test-debug cycles. Valdi offers instant hot reloading—see changes in milliseconds across platforms without rebuilding. Debugging is a breeze with full VSCode integration: set breakpoints, inspect variables, profile performance, and even capture heap dumps. This setup is particularly helpful for teams transitioning from web to mobile development, as it maintains a modern, iterative feel.
Third, seamless integration with existing codebases. Valdi’s flexible adoption model lets you start small. Embed Valdi components into your current UIKit or Android hierarchies using native bindings, or incorporate custom native views into Valdi layouts via the <custom-view> element. For performance-critical sections, polyglot modules allow you to write in C++, Swift, Kotlin, or Objective-C, with automatic type-safe bindings to TypeScript. This bidirectional communication handles complex data and callbacks effortlessly.
Additionally, Valdi excels in advanced scenarios. It includes Flexbox for layouts with automatic right-to-left (RTL) support, native animations for a polished user experience, and sophisticated gesture recognition handled natively by the platform. Protobuf integration ensures efficient data serialization, while the full-stack architecture lets you build entire features within Valdi, reducing the need for platform-specific bridges.
Proven at scale, Valdi has managed complex tasks like real-time rendering and gesture systems in production apps. If your project involves multimedia, social features, or data-intensive UIs, these capabilities can save you significant time and effort.
To give you a clearer picture, here’s a comparison table of Valdi versus some common alternatives (based on general framework traits, focusing on Valdi’s strengths):
| Feature | Valdi | React Native | Flutter |
|---|---|---|---|
| Performance | Native compilation, view recycling | Bridge-based, potential latency | Compiled to native ARM, good speed |
| Developer Speed | Hot reload, VSCode debugging | Hot reload, but bridge overhead | Hot reload, widget-based |
| Platform Integration | Deep native bindings, polyglot | Native modules possible | Plugins for native |
| Layout System | Flexbox with RTL | Yoga (Flexbox-like) | Custom widgets |
| Testing | Built-in unit tests | Third-party tools | Integrated testing |
| License | MIT | MIT | BSD |
This table highlights how Valdi prioritizes both ends of the spectrum—velocity and performance—making it a strong contender for hybrid teams.
Getting Started with Valdi: A Step-by-Step Guide
Ready to try Valdi? Setting it up is straightforward, especially if you have experience with TypeScript or native development. Follow these steps to get your first project running.
Step 1: Prepare Your Environment
-
Install Node.js and TypeScript (version 5.x or later). -
For iOS development, you’ll need Xcode; for Android, Android Studio; macOS setup mirrors iOS. -
Clone the Valdi repository (assuming it’s hosted on GitHub under Snapchat/Valdi). -
Install Bazel for building, as it’s integrated for incremental and reproducible compiles.
Step 2: Install Dependencies
Use npm or yarn to pull in required packages. Valdi’s core is lightweight, but ensure you have the valdi_core module for components.
Step 3: Build and Run a Sample
-
Use Bazel commands to build your project. -
Start with the “Hello World” example above. Place it in a component file. -
Enable hot reloading for quick iterations. -
Run on simulators or devices: for iOS, use Xcode; for Android, Android Studio.
For embedding in existing apps, refer to the native-bindings documentation. It explains how to drop Valdi views into your hierarchy. Conversely, for custom native elements in Valdi, use the <custom-view> tag with appropriate props.
If you encounter issues, the Getting Started Guide in docs/INSTALL.md covers troubleshooting. Valdi also has codelabs for hands-on tutorials, walking you through basic to advanced setups.
Step 4: Explore Documentation and APIs
Valdi’s docs are comprehensive. Start with the README for an overview, then dive into API references for components like views, labels, and more. For performance tweaks, check the optimization guide. Advanced topics include animations, touches, and worker services.
A upcoming component library at https://github.com/Snapchat/Valdi_Widgets will provide pre-built widgets, saving you even more time.
Optimizing Performance in Valdi Applications
Performance is Valdi’s strong suit, but knowing how to leverage it fully can elevate your app. Here’s a detailed how-to guide based on best practices.
How to Implement View Recycling Effectively
Valdi’s global pooling system reuses views automatically, but design your components to be stateless where possible. Avoid tying state to specific view instances. Test with large datasets to see the benefits in reduced inflation times.
How to Optimize Rendering Cycles
Use shouldComponentUpdate to prevent unnecessary re-renders. Break UIs into small, independent components. This granular approach ensures updates are fast and localized.
How to Utilize Worker Threads
For off-main-thread tasks like data processing, set up worker services. This keeps the UI responsive. Example: Move network calls or computations to workers, syncing back via callbacks.
How to Fine-Tune Layouts
Leverage Flexbox for flexible, responsive designs. Test RTL modes for international apps. The C++ engine handles complexity well, but profile with VSCode tools to identify bottlenecks.
How to Enable Viewport-Aware Rendering
In scrollable lists, configure views to inflate only when in viewport. This is default for many components but customizable for custom scenarios.
Following these steps, you can achieve sub-millisecond updates even in demanding apps. For more, see the performance-optimization.md doc.
Integrating Native Code with Valdi
One of Valdi’s standout features is its support for polyglot development. If you need to tap into platform-specific APIs or third-party libraries, here’s how.
Step 1: Define Interfaces with Annotations
Use Valdi’s annotation system to create TypeScript interfaces. These auto-generate bindings for Kotlin, Objective-C, and Swift.
Step 2: Implement in Native Languages
Write your logic in the chosen language, exposing methods that match the interface. Valdi handles type safety.
Step 3: Call from TypeScript
Import the module in your component and invoke functions. Pass data structures or callbacks—everything flows bidirectionally without marshaling issues.
This approach is perfect for integrating features like camera access or hardware sensors. Details in native-polyglot.md.
Valdi’s Community Guidelines and Code of Conduct
A healthy community is key to any open-source project’s success. Valdi adopts a Code of Conduct inspired by the Contributor Covenant version 2.1, promoting inclusivity and respect.
We pledge to create a harassment-free environment for all, irrespective of age, body size, disability, ethnicity, gender identity, experience level, education, socio-economic status, nationality, appearance, race, caste, color, religion, or sexual orientation. Positive behaviors include showing empathy, respecting diverse views, giving constructive feedback, owning mistakes, and prioritizing community well-being.
Unacceptable actions encompass sexualized content, trolling, insults, harassment, doxxing, or other unprofessional conduct. Community leaders enforce these standards, with rights to moderate contributions and explain decisions.
The scope covers all community spaces and public representations. Report issues to opensource@snap.com for prompt, fair investigation, respecting privacy.
Enforcement follows graduated guidelines:
-
Correction: For minor issues like inappropriate language—a private warning and possible apology. -
Warning: For violations—a no-interaction period, with escalation risks. -
Temporary Ban: For serious breaches—a timed suspension. -
Permanent Ban: For patterns of harm—a lifelong exclusion.
This structure ensures fairness while maintaining a welcoming space. For FAQs, visit the Contributor Covenant’s site.
Contributing to Valdi: Guidelines and Best Practices
Valdi thrives on community input. Whether fixing bugs, enhancing docs, or optimizing tests, your contributions matter.
How to Contribute Code or Docs
-
Review the Code of Conduct and Contributing guidelines. -
Fork the repo and branch off. -
Make changes adhering to standards: match existing style, document thoroughly, test additions, avoid extra deps. -
Use descriptive commits, e.g., “feat: Add gesture support” or “docs: Clarify installation.” -
Run tests to verify. -
Submit a PR with a clear description.
For new features, discuss on Discord first: https://discord.gg/uJyNEeYX2U.
Legal Considerations for Contributors
By contributing, you affirm originality or rights to submit, granting MIT license usage. Patent holders provide royalty-free licenses. Waive moral rights where possible. Ensure third-party code is compatible and attributed—no CLA required.
Recognition comes via the All Contributors spec, crediting all types of help.
Reporting Issues Effectively
Open issues with details: reproduction steps, OS/Valdi version, expected vs. actual behavior, suspected causes. This helps maintainers triage quickly.
Advanced Features in Valdi: A Closer Look
Valdi shines in sophisticated use cases. Here’s a table summarizing key advanced capabilities:
| Feature | Description | Benefits |
|---|---|---|
| Native Animations | Platform-specific animations for fluid transitions | Enhances user engagement with natural feel |
| Gesture Recognition | Native handling of touches, swipes, etc. | Responsive interactions without custom code |
| Worker Threads | Multi-threaded JS for background work | Keeps UI snappy during intensive tasks |
| Protobuf Support | Efficient serialization for data exchange | Reduces bandwidth and parsing time |
| Full-Stack Builds | End-to-end features in Valdi, minimal bridges | Streamlines development for complex apps |
| Bazel Integration | Incremental, reproducible builds | Speeds up large-scale projects |
| Hermes Debugging | VSCode tools for breakpoints, profiling | Easier bug hunting and optimization |
These features make Valdi versatile for everything from simple prototypes to enterprise-level apps.
Frequently Asked Questions About Valdi
To address common queries:
What platforms does Valdi support?
iOS, Android, and macOS, with native views on each.
Is Valdi free and open-source?
Yes, under MIT license.
How does Valdi handle internationalization?
Flexbox includes automatic RTL support.
Can I use Valdi for desktop apps?
Primarily mobile, but macOS support extends to desktops.
What’s the difference between Valdi and other frameworks?
Focus on native compilation and performance optimizations sets it apart.
How do I get help if stuck?
Join the Discord community for real-time support.
Is there a roadmap for Valdi?
Beta focuses on DX; post-beta, more widgets and features.
Why Valdi Could Be the Future of Cross-Platform UI Development
In a landscape crowded with options, Valdi’s blend of performance, flexibility, and community focus positions it uniquely. For graduates entering the field, it’s a great way to learn modern practices. For pros, it accelerates delivery without sacrifices.
If you’re intrigued, start with the docs, contribute a small fix, or join discussions. Valdi isn’t just a tool—it’s a step toward more efficient, inclusive development.


