What is Preact? When do you need it?

Most people in the programming field are familiar with React since it is most often used for building Single Page Applications. It's popular because of its strong community, fast performance, and clean programming. Preact is a lightweight version of React. Preact is a JavasScript library. Preact claims that it is a fast 3kb alternative to React. Compared to other frameworks it is the fastest virtual DOM. To run a simple PReactJS  app in the browser you don’t need to install any build tools. It has a dedicated CLI. It can easily integrate with any existing React projects. At the same time it differs from React in the following ways:

  • this.props, this.state are passed directly to render() method.

  • You can use class to pass CSS classes instead of using className.

  • No support for PropType validation in base core.

  • No support for Synthetic Events.

If you want your application to load in a short time and your users have slow internet connection then you should try Preact. Your bundle size will be smaller and the app will load faster in Preact. To build small web widgets, landing pages, PWA you can choose Preact without any doubt.

To install PReact CLI run the npm command.


npm install -g preact-cli
To create a new project type the command below.

preact create <template-name> <project-name>

There are some templates available to get started with PReact they are: default, simple, Material, Netlify CMS, TypeScript, Widget.