Capsules, reactive state, and HSR: Perseus v0.4.0 goes stable!

71 points arctic_hen7

Perseus is a pure Rust web development framework with support for static site generation, server-side rendering, client-side rendering, reactive state, internationalization, capsules (sometimes called an 'islands architecture'), seamless deployment, custom API routes, and so much more! And, after a year of beta versions, v0.4.0 of it just went stable!

This release is full of major new features, especially the capsules system, which lets you load parts of your app separately and cache them for use in other pages, letting you speed up your site with fine-grained control present in no other web framework today. Perfect Lighthouse scores on desktop (and so nearly on mobile, pending better Wasm support in mobile browsers) have been maintained, facilitated by a full rewrite of the Perseus core to improve speed and stability, and integral components of the framework, like the error management system, have been radically overhauled to improve ergonomics and performance.

But the biggest feature in this release is actually from v0.3.4, a minor release of Perseus that experimented with something called hot state reloading (HSR). In the JavaScript world, there's a thing called hot module reloading (HMR) that lets you reload your app in exactly the same place as you left off, which is very helpful when you're ten states deep into a login form and you want to move a button over by 1px without losing where you are. But, because Wasm doesn't support chunking yet (i.e. splitting your app up into many smaller files), this has never been possible in Rust web frameworks...until now. Perseus v0.4.0 is able to take the entire state of your app, freeze it to a string, and chuck it in the browser for later thawing. Not only does this allow apps to easily bring users back to exactly where they were when they last logged in, it also lets developers maintain their progress when testing complicated parts of their apps, and all in a few hundred lines of pure Rust! Oh, and did we mention compile times are faster too now?

Overall, this version is a major milestone for the Perseus team, and we really hope the features in this release will be useful to many people: we've wanted to see this kind of stuff in a framework for ages, and, after a year of beta versions, now we can. Not just that, but the complexity of some of these features, especially of the capsules system, is a testament to the power of the Rust language: we rewrote the Perseus core over a month, over 20,000 lines of code, and, bar one BorrowMut error, it worked first time. Only in Rust is that possible!

If you want to learn more about this release, you can check out the formal announcement here, and you can take a look at our spritzed-up new website (made in Perseus of course) here! Also, please consider giving the project a star on GitHub if you like it!