---
url: /guide/start/index.md
---
# Introduction
Rsbuild is a high-performance build tool powered by Rspack. It provides carefully designed defaults for an out-of-the-box development experience while fully leveraging Rspack's performance.
Rsbuild provides a [rich set of build features](/guide/start/features), including support for TypeScript, JSX, Sass, Less, CSS Modules, Wasm, and more. It also supports Module Federation, image compression, type checking, PostCSS, Lightning CSS, and additional features.
## 🚀 Performance
Powered by Rspack's Rust-based architecture, Rsbuild delivers blazing-fast performance to speed up your development workflow.
Time to build a large web application:
import { BenchmarkGraph } from '@components/Benchmark';
> 📊 Benchmark results from [build-tools-performance](https://github.com/rstackjs/build-tools-performance).
## 💡 Comparisons
Rsbuild is comparable to [Vite](https://vitejs.dev/), [Create React App](https://github.com/facebook/create-react-app), and [Vue CLI](https://github.com/vuejs/vue-cli). Each of these tools includes a built-in dev server, command-line tools, and sensible defaults for an out-of-the-box experience.

### CRA / Vue CLI
You can think of Rsbuild as a modernized version of Create React App or Vue CLI, with these key differences:
- The underlying bundler has been switched from webpack to Rspack, delivering 5 to 10 times better build performance.
- It's decoupled from frontend UI frameworks and supports all frameworks via [plugins](/plugins/list/index), including React, Vue, Svelte, Solid, and more.
- It is more extensible. You can extend Rsbuild through [configurations](/config/index), the [Plugin API](/plugins/dev/index), and the [JavaScript API](/api/start/index).
### Vite
Rsbuild has many similarities to Vite, as both aim to improve the frontend development experience. The main differences are:
- **Production consistency**: Rsbuild uses Rspack for bundling in both development and production builds, ensuring high consistency between development and production outputs. Vite uses ESM during development for faster startup, but this approach can introduce inconsistencies between development and production outputs.
- **Ecosystem compatibility**: Rsbuild is compatible with most webpack plugins and all Rspack plugins, while Vite is compatible with Rollup plugins. If you're using many plugins and loaders from the webpack ecosystem, migration to Rsbuild is more straightforward.
- **Module Federation**: The Rsbuild team works closely with the [Module Federation](/guide/advanced/module-federation) development team, providing first-class support for Module Federation to help you develop large web applications with micro-frontend architecture.
## 🔥 Features
Rsbuild has the following features:
- **Easy to configure**: One of Rsbuild's goals is to give Rspack users out-of-the-box build capabilities so they can start web projects with zero configuration. Rsbuild also provides a semantic build configuration API to reduce the Rspack learning curve.
- **Performance-focused**: Rsbuild integrates high-performance Rust-based tools from the community, including [Rspack](https://rspack.rs), [SWC](https://swc.rs/), and [Lightning CSS](https://lightningcss.dev/), delivering first-class build speed and development experience.
- **Plugin ecosystem**: Rsbuild has a lightweight plugin system and includes a range of high-quality official plugins. It is also compatible with most webpack plugins and all Rspack plugins, allowing you to use existing community or in-house plugins without rewriting code.
- **Stable artifacts**: Rsbuild places a strong focus on build artifact stability. It ensures consistent artifacts in development and production builds, and automatically handles syntax downgrading and polyfill injection. Rsbuild also provides plugins for type checking and artifact syntax validation to prevent quality and compatibility issues from reaching production code.
- **Framework agnostic**: Rsbuild is not coupled to any frontend UI framework. It supports frameworks like React, Vue, Svelte, Solid, and Preact through plugins, with plans to support more UI frameworks from the community in the future.
## 🦀 Rstack
Rstack is a unified JavaScript toolchain centered on Rspack, with high performance and consistent architecture.
Rstack includes the following tools:
| Name | Description | Version |
| ----------------------------------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Rspack](https://github.com/web-infra-dev/rspack) | Bundler | |
| [Rsbuild](https://github.com/web-infra-dev/rsbuild) | Build tool | |
| [Rslib](https://github.com/web-infra-dev/rslib) | Library development tool | |
| [Rspress](https://github.com/web-infra-dev/rspress) | Static site generator | |
| [Rsdoctor](https://github.com/web-infra-dev/rsdoctor) | Build analyzer | |
| [Rstest](https://github.com/web-infra-dev/rstest) | Testing framework | |
| [Rslint](https://github.com/web-infra-dev/rslint) | Linter | |
## 🔗 Links
- [awesome-rstack](https://github.com/rstackjs/awesome-rstack): A curated list of awesome things related to Rstack.
- [rstack-examples](https://github.com/rstackjs/rstack-examples): Examples showcasing Rstack tools.
- [storybook-rsbuild](https://github.com/rstackjs/storybook-rsbuild): Storybook builder powered by Rsbuild.
- [rsbuild-plugin-template](https://github.com/rstackjs/rsbuild-plugin-template): Use this template to create your own Rsbuild plugin.
- [rstack-design-resources](https://github.com/rstackjs/rstack-design-resources): Design resources for Rstack.
## 🧑💻 Community
Come and chat with us on [Discord](https://discord.gg/XsaKEEk4mW)! The Rstack team and users are active there, and we're always looking for contributions.
## ✨ Next step
Next, you may want to:
import NextSteps from '@components/NextSteps';
import Step from '@components/Step';
---
url: /guide/start/quick-start.md
---
# Quick start
## Online examples
We provide online Rsbuild examples that showcase Rspack's build performance and Rsbuild's development experience:
- [StackBlitz example](https://stackblitz.com/~/github.com/rstackjs/rsbuild-stackblitz-example)
- [CodeSandbox example](https://codesandbox.io/p/github/rstackjs/rsbuild-codesandbox-example)
## Environment preparation
Rsbuild supports using [Node.js](https://nodejs.org/), [Deno](https://deno.com/), or [Bun](https://bun.sh/) as the JavaScript runtime.
Use one of the following installation guides to set up a runtime:
- [Install Node.js](https://nodejs.org/en/download)
- [Install Bun](https://bun.com/docs/installation)
- [Install Deno](https://docs.deno.com/runtime/getting_started/installation/)
:::tip Version requirements
- Rsbuild >= v1.5.0 requires Node.js 18.12.0 or higher.
- Rsbuild < 1.5.0 requires Node.js 16.10.0 or higher.
:::
## Create an Rsbuild application
Use [create-rsbuild](https://www.npmjs.com/package/create-rsbuild) to create a new Rsbuild application. Run the following command:
import { PackageManagerTabs } from '@theme';
Follow the prompts to choose options, such as whether to add optional tools like TypeScript and ESLint.
After creating the application, do the following:
- Run `git init` to initialize a Git repository.
- Run `npm install` (or your package manager's install command) to install dependencies.
- Run `npm run dev` to start the dev server, which runs on `http://localhost:3000` by default.
### Templates
When creating an application, you can choose from the following templates provided by `create-rsbuild`:
| Template | Official docs | Rsbuild integration guide |
| -------- | ------------------------------- | --------------------------------------- |
| vanilla | Native JavaScript | - |
| react | [React 19](https://react.dev/) | [Using React](/guide/framework/react) |
| react18 | [React 18](https://react.dev/) | [Using React](/guide/framework/react) |
| vue | [Vue 3](https://vuejs.org/) | [Using Vue](/guide/framework/vue) |
| vue2 | [Vue 2](https://v2.vuejs.org/) | [Using Vue](/guide/framework/vue) |
| lit | [Lit](https://lit.dev/) | - |
| preact | [Preact](https://preactjs.com/) | [Using Preact](/guide/framework/preact) |
| svelte | [Svelte](https://svelte.dev/) | [Using Svelte](/guide/framework/svelte) |
| solid | [Solid](https://solidjs.com/) | [Using Solid](/guide/framework/solid) |
`create-rsbuild` provides basic templates. For more options, see:
- Visit [Rspack - Ecosystem](https://rspack.rs/guide/start/quick-start#ecosystem) to learn about higher-level tools built on Rsbuild.
- Visit [awesome-rstack - Starter](https://github.com/rstackjs/awesome-rstack?tab=readme-ov-file#starter) for community-maintained templates.
### Optional tools
`create-rsbuild` can help you set up commonly used tools, including [Rstest](https://rstest.rs), [Biome](https://github.com/biomejs/biome), [ESLint](https://github.com/eslint/eslint), [Prettier](https://github.com/prettier/prettier), [Tailwind CSS](https://tailwindcss.com) and [Storybook](https://storybook.js.org/). Use the arrow keys to navigate and the space bar to select. Press Enter without selecting anything to skip these tools.
```
◆ Select additional tools (Use to select, to continue)
│ ◻ Rstest - testing
│ ◻ Biome - linting & formatting
│ ◻ ESLint - linting
│ ◻ Prettier - formatting
│ ◻ Tailwind CSS - styling
│ ◻ Storybook - component development
└
```
:::tip
Biome provides similar linting and formatting features to ESLint and Prettier. If you select Biome, you typically won't need to add ESLint or Prettier.
:::
### Current directory
To create an application in the current directory, set the target folder to `.`:
```
◆ Create Rsbuild Project
│
◇ Project name or path
│ .
│
◇ "." is not empty, please choose:
│ Continue and override files
```
### Non-interactive mode
[create-rsbuild](https://npmjs.com/package/create-rsbuild) supports a non-interactive mode via command-line options. This mode skips prompts and creates the project directly, which is useful for scripts, CI, and automation.
For example, the following command creates a React app in the `my-app` directory:
```bash
npx -y create-rsbuild@latest my-app --template react
# Using abbreviations
npx -y create-rsbuild@latest my-app -t react
# Specify multiple tools
npx -y create-rsbuild@latest my-app -t react --tools eslint,prettier
```
All CLI flags supported by `create-rsbuild`:
```
Usage: create-rsbuild [dir] [options]
Options:
-h, --help display help for command
-d, --dir create project in specified directory
-t, --template specify the template to use
--tools add additional tools, comma separated
--override override files in target directory
--packageName specify the package name
Templates:
react-js, react-ts, vue3-js, vue3-ts, vue2-js, vue2-ts, svelte-js, svelte-ts,
solid-js, solid-ts, vanilla-js, vanilla-ts
Optional tools:
rstest, biome, eslint, prettier, tailwindcss, storybook
```
## Migrate from existing projects
To migrate from an existing project to Rsbuild, refer to the following guides:
- [Migrate from webpack](/guide/migration/webpack)
- [Migrate from Create React App](/guide/migration/cra)
- [Migrate from Vue CLI](/guide/migration/vue-cli)
- [Migrate from Vite](/guide/migration/vite)
- [Migrate from Modern.js Builder](/guide/migration/modern-builder)
- [Migrate from Tsup to Rslib](https://rslib.rs/guide/migration/tsup)
- [Migrate from Storybook to Storybook Rsbuild](https://rspack.rs/guide/migration/storybook)
### Other projects
If your project doesn't match the above migration guides, you can manually install the [@rsbuild/core](https://npmjs.com/package/@rsbuild/core) package:
After installation, use the following documents to configure your project:
- See [CLI](/guide/basic/cli) to learn about available CLI commands.
- See [Plugin List](/plugins/list/index) to select Rsbuild plugins.
- See [Configure Rsbuild](/guide/configuration/rsbuild) to configure Rsbuild.
## CLI
Rsbuild includes a lightweight CLI with commands like `dev` and `build`.
```json title="package.json"
{
"scripts": {
// start the dev server
"dev": "rsbuild dev",
// build for production
"build": "rsbuild build",
// preview the production build locally
"preview": "rsbuild preview"
}
}
```
Refer to the [CLI](/guide/basic/cli) to learn about all available commands and options.
## Entry module
By default, Rsbuild CLI uses `src/index.(js|ts|jsx|tsx)` as the entry module. You can modify the entry module using the [source.entry](/config/source/entry) option.
```ts title="rsbuild.config.ts"
export default {
source: {
entry: {
foo: './src/pages/foo/index.ts',
bar: './src/pages/bar/index.ts',
},
},
};
```
## Core packages
### @rsbuild/core
Core Rsbuild package that provides the CLI commands and JavaScript API.
### create-rsbuild
Create a new Rsbuild project.
## Next step
You may want:
import NextSteps from '@components/NextSteps';
import Step from '@components/Step';
---
url: /guide/start/features.md
---
# Features
Overview of the main features supported by Rsbuild.
## JavaScript
| Features | Description | Links |
| -------------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Rspack | Use Rspack as the bundler by default |
[Configure Rspack](/guide/configuration/rspack)
|
| SWC compilation | Transform and minify JavaScript and TypeScript code using SWC by default |
[Configure SWC](/guide/configuration/swc)
|
| TS compilation | TypeScript files are compiled using SWC by default |
|
## HTML
| Features | Description | Links |
| ------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Set title | Set HTML `` tag |
|
## Server
| Features | Description | Links |
| ----------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------- |
| Public dir | Serves public assets from the `public` directory by default |
[server.publicDir](/config/server/public-dir)
|
| SSR | Optional feature, implement server-side rendering |
[SSR](/guide/advanced/ssr)
|
| Proxy | Optional feature, proxy requests to the specified service |
[server.proxy](/config/server/proxy)
|
| Open page | Optional feature, automatically open page in browser when starting server |
[server.open](/config/server/open)
|
| HTTPS | Optional feature, enable HTTPS server |
|
## Performance and debugging
| Features | Description | Links |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Chunk splitting | A variety of chunk splitting strategies are built into Rsbuild to automatically split the bundle into files of moderate size |
|
---
url: /guide/start/glossary.md
---
# Glossary
## Bundler
Module bundlers like [Rspack](https://rspack.rs/) and [webpack](https://webpack.js.org/).
The main goal of bundlers is to combine JavaScript, CSS, and other files so the output can run in the browser, Node.js, or other environments. When bundlers process web applications, they build a dependency graph and combine each module into one or more bundles.
## CSR
CSR stands for "Client-Side Rendering". It means the page is rendered in the browser using JavaScript, and logic such as data fetching, templates, and routing runs on the client rather than the server.
In CSR, the server sends an empty HTML shell and JavaScript to the browser, and the browser fetches data from the server's API and renders dynamic content.
## Environment
The runtime environment for build outputs. See [Multi-environment builds](/guide/advanced/environments).
## Micro-frontend
Micro-frontend (MFE) is an architecture style similar to microservices. It is composed of multiple independently delivered frontend applications that form a cohesive whole. MFE decomposes frontend applications into smaller, simpler applications that can be developed, tested, and deployed independently while still appearing as a single product to users.
It primarily solves two problems:
- Maintaining large, complex applications becomes difficult over time.
- Cross-team collaboration becomes inefficient.
## Modern.js
[Modern.js](https://github.com/web-infra-dev/modern.js) is an open-source web engineering system from ByteDance that provides multiple solutions to help developers solve problems in different development scenarios.
## Module Federation
Module Federation is an architectural pattern for JavaScript application decomposition (similar to microservices on the server-side), allowing you to share code and resources between multiple JavaScript applications (or micro-frontends).
See [Module Federation](/guide/advanced/module-federation) for more details.
## Rspack
[Rspack](https://rspack.rs/) is a high-performance JavaScript bundler written in Rust. It offers strong compatibility with the webpack ecosystem, so it can replace webpack seamlessly while delivering lightning-fast build speeds.
## Rspress
[Rspress](https://github.com/web-infra-dev/rspress) is a fast static site generator based on Rsbuild.
## SSR
SSR stands for "Server-Side Rendering". It means that the HTML of the web page is generated by the server and sent to the client, rather than sending only an empty HTML shell and relying on JavaScript to generate the page content.
See [Server-side rendering (SSR)](/guide/advanced/ssr) for more details.
## SWC
SWC (Speedy Web Compiler) is a transformer and minifier for JavaScript and TypeScript written in Rust.
See [Configure SWC](/guide/configuration/swc) for more details.
## More
See additional glossary terms in [Rspack - Glossary](https://rspack.rs/misc/glossary).
---
url: /guide/start/ai.md
---
import { PackageManagerTabs } from '@theme';
# AI
To help AI better understand Rsbuild's features, configuration, and best practices so it can provide more accurate assistance during day-to-day development and troubleshooting, Rsbuild provides the following capabilities:
- [Agent Skills](#agent-skills)
- [llms.txt](#llmstxt)
- [Markdown docs](#markdown-docs)
- [AGENTS.md](#agentsmd)
## Agent Skills
Agent Skills are domain-specific knowledge packs that can be installed into Agents, enabling them to give more accurate and professional suggestions or perform actions in specific scenarios.
In the [rstackjs/agent-skills](https://github.com/rstackjs/agent-skills) repository, there are many skills for the Rstack ecosystem. The skills related to Rsbuild include:
- [rsbuild-best-practices](https://github.com/rstackjs/agent-skills#rsbuild-best-practices): Rsbuild best practices.
- [rsbuild-v2-upgrade](https://github.com/rstackjs/agent-skills#rsbuild-v2-upgrade): Upgrade a Rsbuild 1.x project to v2.
- [migrate-to-rsbuild](https://github.com/rstackjs/agent-skills#migrate-to-rsbuild): Migrate webpack, Vite, Create React App, or Vue CLI projects to Rsbuild.
- [storybook-rsbuild](https://github.com/rstackjs/agent-skills#storybook-rsbuild): Set up or migrate Storybook to use the Rsbuild builder.
In Coding Agents that support skills, you can use the [skills](https://www.npmjs.com/package/skills) package to install a specific skill with the following command:
After installation, simply use natural language prompts to trigger the skill, for example:
```
Help me migrate this Vite project to Rsbuild
```
## llms.txt
[llms.txt](https://llmstxt.org/) is a standard that helps LLMs discover and use project documentation. Rsbuild follows this standard and publishes the following two files:
- [llms.txt](https://rsbuild.rs/llms.txt): A structured index file containing the titles, links, and brief descriptions of all documentation pages.
```
https://rsbuild.rs/llms.txt
```
- [llms-full.txt](https://rsbuild.rs/llms-full.txt): A full-content file that concatenates the complete content of every documentation page into a single file.
```
https://rsbuild.rs/llms-full.txt
```
You can choose the file that best fits your use case:
- `llms.txt` is smaller and consumes fewer tokens, making it suitable for AI to fetch specific pages on demand.
- `llms-full.txt` contains the complete documentation content, so AI doesn't need to follow individual links — ideal when you need AI to have a comprehensive understanding of Rsbuild, though it consumes more tokens and is best used with AI tools that support large context windows.
## Markdown docs
Every Rsbuild documentation page has a corresponding `.md` plain-text version that can be provided directly to AI. On any doc page, you can click “Copy Markdown” or “Copy Markdown Link” under the title to get the Markdown content or link.
```
https://rsbuild.rs/guide/start/index.md
```
Providing the Markdown link or content allows AI to focus on a specific chapter, which is useful for targeted troubleshooting or looking up a particular topic.
## AGENTS.md
When you create a new project with [create-rsbuild](https://www.npmjs.com/package/create-rsbuild), the generated project includes an `AGENTS.md` file. This file follows the [AGENTS.md](https://agents.md/) specification and provides key project information to Agents.
Example `AGENTS.md` content:
```markdown wrapCode
# AGENTS.md
You are an expert in JavaScript, Rsbuild, and web application development. You write maintainable, performant, and accessible code.
## Commands
- `npm run dev` - Start the dev server
- `npm run build` - Build the app for production
- `npm run preview` - Preview the production build locally
## Docs
- Rsbuild: https://rsbuild.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
```
You can also customize it for your project, adding more details about the project structure, overall architecture, and other relevant information so Agents can better understand your project.
::: tip
If you are using Claude Code, you can create a `CLAUDE.md` file and reference the `AGENTS.md` file in it.
```markdown title="CLAUDE.md"
@AGENTS.md
```
:::
---
url: /guide/framework/react.md
---
# React
This document explains how to use Rsbuild to build a React application.
## Create a React application
Create a React application with Rsbuild using [create-rsbuild](/guide/start/quick-start#create-an-rsbuild-application). Run this command:
import { PackageManagerTabs } from '@theme';
Then select `React 19` or `React 18` when prompted to "Select framework".
## Use React in an existing project
To compile React's JSX syntax, register the Rsbuild [React Plugin](/plugins/list/plugin-react). The plugin automatically adds the necessary configuration for building React applications.
For example, register in `rsbuild.config.ts`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
export default defineConfig({
plugins: [pluginReact()],
});
```
:::tip
For projects using Create React App, you can refer to the [CRA Migration Guide](/guide/migration/cra).
:::
## Use SVGR
Rsbuild supports converting SVG to React components via [SVGR](https://react-svgr.com/).
To use SVGR, register the [SVGR plugin](/plugins/list/plugin-svgr).
## React Fast Refresh
Rsbuild uses React's official [Fast Refresh](https://npmjs.com/package/react-refresh) capability to perform component hot updates.
React Refresh requires components to follow certain standards, or HMR may not work. Use [eslint-plugin-react-refresh](https://github.com/ArnaudBarre/eslint-plugin-react-refresh) to validate your code.
If React component hot updates don't work, or component state is lost after updates, your React component is likely using an anonymous function. React Fast Refresh requires named functions to preserve component state after hot updates.
Here are some examples of wrong usage:
```tsx
// bad
export default function () {
return
Hello World
;
}
// bad
export default () =>
Hello World
;
```
The correct usage is to declare a name for each component function:
```tsx
// good
export default function MyComponent() {
return
Hello World
;
}
// good
const MyComponent = () =>
Hello World
;
export default MyComponent;
```
## React Compiler
React Compiler is a build-time tool that automatically optimizes your React app. It works with plain JavaScript, and understands the Rules of React, so you don’t need to rewrite any code to use it.
Before using React Compiler, we recommend reading the [React Compiler documentation](https://react.dev/learn/react-compiler) to understand its functionality, current state, and usage.
### How to use
Steps to use React Compiler in Rsbuild:
1. Upgrade `react` and `react-dom` to v19. If you can't upgrade, install the [react-compiler-runtime](https://npmjs.com/package/react-compiler-runtime) package to run the compiled code on earlier versions.
2. React Compiler currently only provides a Babel plugin. Install [@rsbuild/plugin-babel](/plugins/list/plugin-babel) and [babel-plugin-react-compiler](https://npmjs.com/package/babel-plugin-react-compiler).
3. Register the Babel plugin in your Rsbuild config file:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginBabel } from '@rsbuild/plugin-babel';
import { pluginReact } from '@rsbuild/plugin-react';
export default defineConfig({
plugins: [
pluginReact(),
pluginBabel({
include: /\.[jt]sx?$/,
exclude: [/[\\/]node_modules[\\/]/],
babelLoaderOptions(opts) {
opts.plugins?.unshift('babel-plugin-react-compiler');
},
}),
],
});
```
:::tip
The `include` pattern uses `/\.[jt]sx?$/` to match `.js`, `.jsx`, `.ts`, and `.tsx` files. This ensures React Compiler can optimize both components and [custom hooks](https://react.dev/learn/reusing-logic-with-custom-hooks), which are often defined in plain `.ts` files. The `exclude` for `node_modules` prevents the compiler from processing third-party dependencies.
If you only want to compile JSX/TSX files, you can use `include: /\.(?:jsx|tsx)$/` instead, but custom hooks in `.ts` files will not be optimized.
:::
> You can also refer to the [example project](https://github.com/rstackjs/rstack-examples/tree/main/rsbuild/react-compiler-babel).
### Configuration
Set the config for React Compiler as follows:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginBabel } from '@rsbuild/plugin-babel';
import { pluginReact } from '@rsbuild/plugin-react';
const ReactCompilerConfig = {
/* ... */
};
export default defineConfig({
plugins: [
pluginReact(),
pluginBabel({
include: /\.[jt]sx?$/,
exclude: [/[\\/]node_modules[\\/]/],
babelLoaderOptions(opts) {
opts.plugins?.unshift([
'babel-plugin-react-compiler',
ReactCompilerConfig,
]);
},
}),
],
});
```
For React 17 and 18 projects, install [react-compiler-runtime](https://npmjs.com/package/react-compiler-runtime) and specify the `target`:
```ts title="rsbuild.config.ts"
const ReactCompilerConfig = {
target: '18', // '17' | '18' | '19'
};
```
## Router
### TanStack Router
[TanStack Router](https://tanstack.com/router/) is a fully type-safe React router with built-in data fetching, stale-while revalidate caching and first-class search-param APIs.
TanStack Router provides `@tanstack/router-plugin` to integrate with Rsbuild, which provides support for file-based routing. See:
- [Installation guide](https://tanstack.com/router/latest/docs/framework/react/installation/with-rspack)
- [Example project](https://github.com/TanStack/router/tree/main/examples/react/quickstart-rspack-file-based)
### React Router
[React Router](https://reactrouter.com/) is a user‑obsessed, standards‑focused, multi‑strategy router for React.
- To use React Router as a library, you can just follow the official documentation and no configuration is required.
- To use React Router as a framework, the community is working on an experimental Rsbuild plugin, see [rsbuild-plugin-react-router](https://github.com/rstackjs/rsbuild-plugin-react-router).
## CSS-in-JS
See [CSS-in-JS](/guide/styling/css-in-js) for how to use CSS-in-JS in Rsbuild.
## Customize JSX
Rsbuild uses SWC to compile JSX. You can customize the functions used by the compiled JSX code:
- If the JSX runtime is `automatic`, use [importSource](/plugins/list/plugin-react#swcreactoptionsimportsource) to customize the import path of the JSX runtime, for example, import from Preact or Emotion.
- If the JSX runtime is `classic`, use `pragma` and `pragmaFrag` to specify the JSX function and Fragment component.
> `@rsbuild/plugin-react` uses `automatic` as the default JSX runtime, see [swcReactOptions.runtime](/plugins/list/plugin-react#swcreactoptionsruntime).
### Via configuration
Configure through the `@rsbuild/plugin-react`'s [swcReactOptions](/plugins/list/plugin-react#swcreactoptions).
- If `runtime` is `automatic`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
export default defineConfig({
plugins: [
pluginReact({
swcReactOptions: {
runtime: 'automatic',
importSource: '@emotion/react',
},
}),
],
});
```
- If `runtime` is `classic`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
export default defineConfig({
plugins: [
pluginReact({
swcReactOptions: {
runtime: 'classic',
pragma: 'h',
pragmaFrag: 'Fragment',
},
}),
],
});
```
### Via comments
You can also customize JSX behavior by adding specific comments at the top of individual JSX or TSX files, which will take precedence over the configuration.
- If the JSX runtime is `automatic`:
```tsx title="App.tsx"
/** @jsxImportSource custom-jsx-library */
const App = () => {
return
Hello World
;
};
```
- If the JSX runtime is `classic`:
```tsx title="App.tsx"
/** @jsx Preact.h */
/** @jsxFrag Preact.Fragment */
const App = () => {
return
Hello World
;
};
```
## Performance profiling
### React Scan
React Scan can automatically detect performance issues in your React app.
See [React Scan - Rsbuild Guide](https://github.com/aidenybai/react-scan/blob/main/docs/installation/rsbuild.md) to learn how to use React Scan with Rsbuild.
---
url: /guide/framework/vue.md
---
# Vue
This document explains how to build a Vue 3 or Vue 2 application using Rsbuild.
## Create a Vue application
Create a Vue application with Rsbuild using [create-rsbuild](/guide/start/quick-start#create-an-rsbuild-application). Run this command:
import { PackageManagerTabs } from '@theme';
Then select `Vue 3` or `Vue 2` when prompted to "Select framework".
## Vue 3
### Use Vue in an existing project
To compile Vue SFC (Single File Components), register the Rsbuild [Vue plugin](/plugins/list/plugin-vue). The plugin automatically adds the necessary configuration for Vue builds.
For example, register in `rsbuild.config.ts`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginVue } from '@rsbuild/plugin-vue';
export default defineConfig({
plugins: [pluginVue()],
});
```
:::tip
For projects using Vue CLI, you can refer to the [Vue CLI Migration Guide](/guide/migration/vue-cli).
:::
### Use the JSX syntax of Vue
To use the JSX syntax of Vue, you also need to register the [@rsbuild/plugin-vue-jsx](https://github.com/rstackjs/rsbuild-plugin-vue-jsx).
### TypeScript support
Rsbuild supports compiling TypeScript by default.
Please refer to the [TypeScript - IDE Support](https://vuejs.org/guide/typescript/overview.html#ide-support) section of the Vue documentation to learn how to set up Vue TypeScript support in your IDE.
## Vue 2
### Use Vue 2 in an existing project
To compile Vue SFC (Single File Components), you need to register the Rsbuild [Vue 2 plugin](https://github.com/rstackjs/rsbuild-plugin-vue2). The plugin will automatically add the necessary configuration for Vue builds.
For example, register in `rsbuild.config.ts`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginVue2 } from '@rsbuild/plugin-vue2';
export default defineConfig({
plugins: [pluginVue2()],
});
```
:::tip
- The Vue 2 plugin only supports Vue >= 2.7.0.
- For projects using Vue CLI, you can refer to the [Vue CLI Migration Guide](/guide/migration/vue-cli).
:::
### Use the JSX syntax of Vue
To use the JSX syntax of Vue, you also need to register the [@rsbuild/plugin-vue2-jsx](https://github.com/rstackjs/rsbuild-plugin-vue2-jsx).
### Type declarations
In a TypeScript project, you need to add type definitions for `*.vue` files so that TypeScript can recognize them correctly.
Create `env.d.ts` in the `src` directory and add the following content:
```ts title="src/env.d.ts"
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
}
```
---
url: /guide/framework/preact.md
---
# Preact
In this document, you will learn how to build a Preact application using Rsbuild.
## Create a Preact application
Use [create-rsbuild](/guide/start/quick-start#create-an-rsbuild-application) to create a Preact application with Rsbuild. Run the following command:
import { PackageManagerTabs } from '@theme';
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](/plugins/list/plugin-preact). The plugin will automatically add the necessary configuration for Preact builds.
For example, register in `rsbuild.config.ts`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginPreact } from '@rsbuild/plugin-preact';
export default defineConfig({
plugins: [pluginPreact()],
});
```
## Preact Fast Refresh
Preact plugin uses [@preact/prefresh](https://github.com/preactjs/prefresh) and [@rspack/plugin-preact-refresh](https://github.com/rstackjs/rspack-plugin-preact-refresh) to hot reload Preact components.
### Component recognition
Prefresh needs to be able to recognize your components. This means that components should
start with a capital letter and hooks should start with `use` followed by a capital letter.
This allows the plugin to effectively recognize these.
Do note that a component as seen below is not named:
```jsx
export default () => {
return
;
};
export default MyComponent;
```
When you are working with HOC's be sure to lift up the `displayName` so the plugin can
recognize it as a component.
---
url: /guide/framework/svelte.md
---
# Svelte
In this document, you will learn how to build a Svelte application using Rsbuild.
## Create a Svelte application
Use [create-rsbuild](/guide/start/quick-start#create-an-rsbuild-application) to create a Svelte application with Rsbuild. Run the following command:
import { PackageManagerTabs } from '@theme';
Then select `Svelte` when prompted to "Select framework".
## Use Svelte in an existing project
To compile Svelte components (`.svelte` files), you need to register the Rsbuild [Svelte plugin](/plugins/list/plugin-svelte). The plugin will automatically add the necessary configuration for Svelte builds.
For example, register in `rsbuild.config.ts`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginSvelte } from '@rsbuild/plugin-svelte';
export default defineConfig({
plugins: [pluginSvelte()],
});
```
---
url: /guide/framework/solid.md
---
# Solid
In this document, you will learn how to build a Solid application using Rsbuild.
## Create a Solid application
Use [create-rsbuild](/guide/start/quick-start#create-an-rsbuild-application) to create a Solid application with Rsbuild. Run the following command:
import { PackageManagerTabs } from '@theme';
Then select `Solid` when prompted to "Select framework".
## Use Solid in an existing project
To compile Solid components, you need to register the Rsbuild [Solid plugin](/plugins/list/plugin-solid). The plugin will automatically add the necessary configuration for Solid builds.
For example, register in `rsbuild.config.ts`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginBabel } from '@rsbuild/plugin-babel';
import { pluginSolid } from '@rsbuild/plugin-solid';
export default defineConfig({
plugins: [
pluginBabel({
include: /\.(?:jsx|tsx)$/,
}),
pluginSolid(),
],
});
```
---
url: /guide/basic/cli.md
---
# CLI
Rsbuild includes a lightweight CLI with commands like [rsbuild dev](#rsbuild-dev) and [rsbuild build](#rsbuild-build).
## All commands
To view all available CLI commands, run this command in your project directory:
```bash
npx rsbuild -h
```
The output is shown below:
```
Usage:
$ rsbuild [command] [options]
Commands:
dev Start the dev server
build Build the app for production
preview Preview the production build locally
inspect Inspect the Rspack and Rsbuild configurations
```
## Common flags
The Rsbuild CLI includes several common flags that work with all commands:
| Flag | Description |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `--base ` | Set the base path of the server, see [server.base](/config/server/base) |
| `-c, --config ` | Set the configuration file (relative or absolute path), see [Specify config file](/guide/configuration/rsbuild#specify-config-file) |
| `--config-loader ` | Set the config file loader (`auto` \| `jiti` \| `native`), see [Specify config loader](/guide/configuration/rsbuild#specify-config-loader) |
| `--env-mode ` | Set the env mode to load the `.env.[mode]` file, see [Env mode](/guide/advanced/env-vars#env-mode) |
| `--env-dir ` | Set the directory for loading `.env` files, see [Env directory](/guide/advanced/env-vars#env-directory) |
| `--environment ` | Set the environment name(s) to build, see [Build specified environment](/guide/advanced/environments#build-specified-environment) |
| `-h, --help` | Display help for command |
| `--log-level ` | Set the log level (`info` \| `warn` \| `error` \| `silent`), see [logLevel](/config/log-level) |
| `-m, --mode ` | Set the build mode (`development` \| `production` \| `none`), see [mode](/config/mode) |
| `--no-env` | Disable loading of `.env` files |
| `-r, --root ` | Set the project root directory (absolute path or relative to [cwd](https://nodejs.org/api/process.html#processcwd)) |
## rsbuild dev
The `rsbuild dev` command starts a local dev server and compiles source code for development.
```bash
Usage: rsbuild dev [options]
Options:
-o, --open [url] Open the page in browser on startup
--port Set the port number for the server
--host Set the host that the server listens to
```
Start the dev server by running `rsbuild` directly (equivalent to `rsbuild dev`):
```bash
npx rsbuild
```
### Opening page
The `--open` option opens a page automatically when the dev server starts (equivalent to setting [server.open](/config/server/open) to `true`).
```bash
rsbuild dev --open
```
The `--open` option also accepts a specific URL to open. For example:
```bash
rsbuild dev --open http://localhost:3000/foo
```
The `--open` option can also be abbreviated to `-o`:
```bash
rsbuild dev -o
```
:::tip
When using both [server.open](/config/server/open) and `--open`, the `--open` option takes precedence.
:::
## rsbuild build
The `rsbuild build` command builds production outputs in the `dist/` directory by default.
```bash
Usage: rsbuild build [options]
Options:
-w, --watch Enable watch mode to automatically rebuild on file changes
```
## rsbuild preview
The `rsbuild preview` command previews production build outputs locally. You must run `rsbuild build` first to generate the outputs.
```bash
Usage: rsbuild preview [options]
Options:
-o, --open [url] Open the page in browser on startup
--port Set a port number for Rsbuild server to listen
--host Set the host that the Rsbuild server listens to
```
:::tip
Use the preview command only for local previews. Do not use it in production, as it is not designed for production servers.
:::
## rsbuild inspect
The `rsbuild inspect` command displays the project's Rsbuild and Rspack configurations.
```bash
Usage: rsbuild inspect [options]
Options:
--output