DEV Community

Cover image for OMI the surprising Chinese Web Components Framework ✨
PiterDev
PiterDev

Posted on

OMI the surprising Chinese Web Components Framework ✨

In my spare time I usually look for promising projects and also see what the big companies are doing in open source.

When I found out that Tencent (the big Chinese company) has a github profile I started looking all the projects. They have a lot of interesting and powerful projects but OMI is amazing 🤯.

Of course it's not a new must framework or anything like that but it has some promising aspects and also things I don't like. More on that later

OMIjs

It is defined itself as a Web Components Framework but in my opinion it goes beyond that . It offers reactive signals, cross framework components, tiny size, fast performance and much more.

By the way OMI uses Vite so it is compatible with all the Vite stuff (like TailwindCSS support, ...).

Now let's look at some code to create the typical Hello World counter :

import { tag, Component, h, render, signal } from 'omi'

const count = signal(0)

@tag('hello-omi')
class HelloOmi extends Component {
  render(props) {
    return (
      <>
        <h1>Hello {props.msg}!</h1>
        {count.value}<button onClick={()=>count.value++}>+</button>
      </>
    )
  }
}

render(<hello-omi msg='Omi' />, 'body')
Enter fullscreen mode Exit fullscreen mode

Counter example OMI

It looks very cool, you can use OOP with reactive signals and also JSX.

I now it is a very strange mix OOP + signals but it feels realy intuitive and easy.

Are you thinking in how can you style your app created in OMI, it is very easy (but uses CSS in JS techniques):


...
class HelloOmi extends Component {

  static css = `h1 { color: #07c160 } `

  render(props) {
     ...
  }
}
Enter fullscreen mode Exit fullscreen mode

Counter example with text in green

This way you can have scoped css but you can also share your styles with other components in other ways.

Cross framework

One of the most exciting features of the framework itself is that it can interact with Vue and React out of the box

Example of Vue working with OMI

As you can see this has a double counter, one controlled by Vue and the other by OMI and they are both synchronised!

If you are interested in this particular aspect and how to code it 👉 Cross Frameworks Guide

Conclusion

OMI looks very fast to develop with, easy to use and embeddable with other frameworks so I might play with it in some project.

It might be difficult at first but it has a good docs site and also a really cool playground

But there is one thing I don't like, CSS in JS but I have to say that the implementation is really good, probably the best CSS in JS I have seen.

Well if you want to check out the project you have here:
🌐 Docs website
📦 Github repo

I hope you really enjoyed this post ♥
If you want to know about other projects I find interesting on Github, let me know below 👇

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay