Build your App, Mini Program, H5, and WeChat official account from one codebase

Author:zhaoyiming0803 Date:2024-11-27

Nothing stays split forever, and nothing stays united forever.

People may use your product from very different places: an H5 in a browser, an app on Android or iOS, or an official-account H5 or a mini program inside a super app like WeChat…

So the tech stack keeps changing and evolving with the business and with how mature the tech is: first it just has to work, then it has to work well, then it has to be built cheaply and fast.

At the very beginning, the same service needed its own code for H5, Android, and iOS — several frontends sitting on top of one backend.

Later you could open an H5 inside an app. That was a basic Hybrid setup, like the official-account H5.

There was a transition period in the middle: to cut network requests, boost performance, and make the first screen load faster, apps started shipping H5 offline packages.

Then mini programs came along and cleaned up and abstracted away the weak spots of the older approach. A mini program is basically an offline package taken to the extreme.

Yes, there are solutions like uniapp, Taro, and Mpx — paired with Vue or React they can raise development efficiency a lot, one code for many ends — but they still can’t cover every scenario a specific business needs.

The end goal is: a user-side app that doesn’t need frequent releases, runs fast, and feels great.

WeChat’s own write-up on how mini programs came to be backs this up:

https://developers.weixin.qq.com/miniprogram/dev/framework/quickstart/#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E7%AE%A5%E4%BD%9C

For a startup, the most important thing is to get a working product into the market fast and prove it works — but only if the foundation isn’t too bad. If it is, the tech will drag the business down later.

From my own experience in startup and new-product projects, I believe this completely.

If you can’t balance business and tech well, you usually end up in one of these two states:

  1. The business looks great early on, then the tech can’t keep up with how fast the business grows, and the product fails.
  2. You over-invest in tech early, doing tech just for tech’s sake, the business drifts away from what users actually need, and the market throws you out.

Product thinking sets the direction; good tech makes the business grow many times faster.

If your code never needs a rewrite, the business is small and its growth is limited.

If your code gets rewritten every few months, the architecture doesn’t fit the current scenario and the planning at the start was weak.

One H5 that serves mini programs, apps, official accounts, and the rest of the ends — that’s the mature solution I settled on after weighing business and tech and after years of stepping in holes. It’s still making money for the partners I work with today.

The hard part of that solution is getting the H5 to talk to the mini program or the app efficiently without hurting performance. On top of that you have to think about iOS review and similar factors, so some features still have to be native. Which means you look at the business scenario and make the trade-off there.

All the projects that are live right now can ship new features right away, and most of the time no review is needed. The H5 performance work also covers a lot of different factors and scenarios.

https://github.com/zhaoyiming0803/into-WebViewJavascriptBridge

I hope every partner’s project makes money, makes money efficiently, and keeps making money efficiently.