Preact

In this document, you will learn how to build a Preact application using Rsbuild.

Create Preact Project

You can use create-rsbuild to create a project with Rsbuild + Preact. Just execute the following command:

npm
yarn
pnpm
bun
npm create rsbuild@latest

Then select Preact when prompted to "Select framework".

Use Preact in an existing project

To compile Preact, you need to register the Rsbuild Preact Plugin. The plugin will automatically add the necessary configuration for Preact builds.

For example, register in rsbuild.config.ts:

rsbuild.config.ts
import { defineConfig } from '@rsbuild/core';
import { pluginPreact } from '@rsbuild/plugin-preact';

export default defineConfig({
  plugins: [pluginPreact()],
});