Hacker News new | ask | show | jobs
by jamwaffles 2281 days ago
I’ve been looking to switch to it. What’s bad about it?
2 comments

Preact is great by itself, and works very well. All the advantages are true, it's fast and about 10x smaller than React [1]. It's GREAT for super-small interactive apps that need to be fast.

But if you try to use it as a drop-in replacement for React [2] and use a lot of third-party React components, Redux, React Router, then you might run into incompatibilities. React is very large and some components rely on obscure behavior, sometimes bugs. You'll have to do some deep diving and opening PRs in third-party repos, and a lot of those people will even deny those PRs.

But honestly: if you're gonna use third-party stuff, Redux, React Router, all that... is the ~38kb it saves really all that much?

If you're doing startup-style development where number of dependencies don't matter, go with React. If you're aiming for an app with only 30kb or 50kb of gzipped Javascript, maybe try Preact.

I'd it's actually more of a competitor to Svelte or to VanillaJS, not to React.

--

[1] 3750 vs 42623 gzipped for the UMD, last I checked. Used the UMD production dist of both of them. Used React+React-DOM concatenated for measuring React.

[2] Sure, maybe they should drop the compatibility line from their "sales" pitch. It mostly works fine, but it's a hard position for them to be in.

I don't think there is anything bad or wrong about using preact. I gave it a shot and for the most part it worked really well. I think the only bad thing I noticed was that not everyone supports it (or at least some parts of it).

I ended up switching back to react due to the fact the react router coupled with typescript didn't work with preact. It's a known issue, and one that's kind of hard to get around if you want to use react router (which my code was already written with). That being said, there are routers that work with preact and typescript, just not react router.

I say give it a try and see if you like it.

Also you can take a look at this for a more in depth comparison https://preactjs.com/guide/v8/differences-to-react/ (at least between preact and react.)