Layr v2 Is Out, but You May Never Use It
Tags: webdev, javascript, typescript, fullstack
Published: 2023-01-13 00:04:13

Finally, after two years of hard work, [Layr v2](https://layrjs.com) is out.

Actually, Layr v2 was published on NPM a year ago, but I haven't announced it because I needed to achieve three important things:

- Documented the new features.
- Created a CLI for Layr, which turned out to be a companion tool called [Boostr](https://boostr.dev).
- Rewrote the ["Hello, World"](https://layrjs.com/docs/v2/introduction/hello-world) tutorial and updated all the [app examples](https://layrjs.com/docs/v2/introduction/introduction?language=ts#examples).

That's all done, and I can now officially announce the release of Layr v2. However, as I will explain later, you may never use it.

> Please check out my [previous article](https://dev.to/mvila/good-bye-web-apis-2bel) if you've never heard of Layr.

## What's New?

Here are the most notable new features in Layr v2.

### Components

- [Attribute sanitization](https://layrjs.com/docs/v2/reference/sanitizer): When you assign a new value to an attribute, this value can be automatically sanitized with some built-in (e.g., `trim()`) or custom sanitization functions.
- [Attribute value assignment](https://layrjs.com/docs/v2/reference/component#attribute-value-assignment): You can now change the value of multiple attributes at once thanks to the component `assign()` class and instance methods.
- [Method scheduling](https://layrjs.com/docs/v2/reference/method#constructor): Class methods have a new `schedule` option to specify that a class method should be repeatedly called with a fixed time delay between each call.
- [Method queuing](https://layrjs.com/docs/v2/reference/method#constructor): Class and instance methods have a new `queue` option to specify that a method should be executed in the background.

### Routing

- [Wrappers](https://layrjs.com/docs/v2/reference/wrapper): A wrapper can be associated with a component class or instance method to wrap any method associated with a route using this wrapper. Thanks to wrappers, you can, for example, easily nest your pages into layouts.
- [Component instance routes](https://layrjs.com/docs/v2/reference/routable#route-decorator): Before, routes could only be associated with component class methods. Now, you can associate routes with component instance methods as well.
- [Catch-all routes](https://layrjs.com/docs/v2/reference/addressable#url-pattern-type): You can now suffix a route URL pattern with a wildcard (`'*'`) to define a route that will be used when no other routes match the current URL. A typical use case is to define a route for displaying a "Not found" page.

### React Integration

- [`page()`](https://layrjs.com/docs/v2/reference/react-integration#page-decorator): A decorator that combines the [`route()`](https://layrjs.com/docs/v2/reference/routable#route-decorator) and [`@view()`](https://layrjs.com/docs/v2/reference/react-integration#view-decorator) decorators.
- [`layout()`](https://layrjs.com/docs/v2/reference/react-integration#layout-decorator): A decorator that combines the [`wrapper()`](https://layrjs.com/docs/v2/reference/routable#wrapper-decorator) and [`@view()`](https://layrjs.com/docs/v2/reference/react-integration#view-decorator) decorators.
- [`useData()`](https://layrjs.com/docs/v2/reference/react-integration#use-data-react-hook): A hook for loading data asynchronously and rendering a React element using these data.
- [`useAction()`](https://layrjs.com/docs/v2/reference/react-integration#use-action-react-hook): A hook for executing some asynchronous actions.

### Command-Line Interface

Layr got a companion tool called [Boostr](https://boostr.dev) for taking care of everything you need to build and deploy your apps.

You can check out the revised ["Hello, World"](https://layrjs.com/docs/v2/introduction/hello-world) tutorial to see Boostr in action.

### Breaking Changes

Layr v2 includes some breaking changes that I will not describe here because, to my knowledge, nobody (except me) has built apps with Layr v1 for production use. Please [let me know](mailto:hi@mvila.me) if it's not the case.

## What's Next?

Some work remains to be done in the documentation:

- Some additional tutorials to cover all the basic features of Layr.
- A "Concepts" section to introduce the fundamental concepts behind Layr.
- A "Guides" section to explain how the most common features of an app could be implemented with Layr.

Unfortunately, writing documentation takes a lot of time, and the Layr project is currently only handled by me, who has to work for customers to make a living and is also starting a new ambitious project called [1Place](https://www.1place.app), which will be based on Layr.

I need to raise money for 1Place, and if everything goes well, I should be able to hire talents to work on 1Place, and, indirectly, fuel the development of Layr.

Also, to build 1Place, some critical features should be added to Layr, such as component subscription and polymorphic storage, which will probably lead to additional breaking changes and a v3 release.

In the current situation, the future of Layr depends on 1Place. If 1Place fails, I'm certainly not going to give up on Layr, which I really care about, but its development will likely be slowed down.

So, for all these reasons, unless you feel very adventurous, I can't recommend building your next app with Layr v2 today.

You may wonder why I am announcing a new version while telling you not to use it. Well, I just felt I had to keep the few people who follow Layr's development informed.