---
url: /guide/start/index.md
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Introduction
Rsbuild is a modern build tool for web applications, powered by [Rspack](https://rspack.rs/).
It delivers fast builds and optimized production output, while keeping configuration simple, consistent, and extensible through plugins.
## 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:
Rsbuild
1.36s dev
3.35s build
160ms hmr
Vite
6.50s dev
1.98s build
130ms hmr
webpack
21.40s dev
28.10s build
2.78s hmr
> 📊 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.md), including React, Vue, Svelte, Solid, and more.
- It is more extensible. You can extend Rsbuild through [configurations](/config/index.md), the [Plugin API](/plugins/dev/index.md), and the [JavaScript API](/api/start/index.md).
### 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.md) 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
Rsbuild is part of Rstack, the fast, unified JavaScript toolchain for developers and agents.

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.
- [agent-skills](https://github.com/rstackjs/agent-skills): A collection of Agent Skills for 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.
## Online example
Try Rsbuild online with the [StackBlitz example](https://stackblitz.com/~/github.com/rstackjs/rsbuild-stackblitz-example).
## Next step
Next, you may want to:
[Quick start
Learn how to use Rsbuild
](/guide/start/quick-start)[All features
Learn all features of Rsbuild
](/guide/start/features)[Support Rsbuild
Support us with a star ⭐️
](https://github.com/web-infra-dev/rsbuild)
---
url: /guide/start/quick-start.md
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Quick start
## 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 v2 requires Node.js version 20.19+, 22.12+.
- Rsbuild v1 requires Node.js 18.12.0 or higher.
:::
## Create an Rsbuild application
[create-rsbuild](https://www.npmjs.com/package/create-rsbuild) lets you quickly create an Rsbuild application. We recommend using [pnpm](https://pnpm.io/) as your package manager.
```sh [pnpm]
pnpm create rsbuild@latest
```
```sh [npm]
npm create rsbuild@latest
```
```sh [yarn]
yarn create rsbuild
```
```sh [bun]
bun create rsbuild@latest
```
```sh [deno]
deno init --npm rsbuild@latest
```
Follow the prompts to complete the setup.
After creating the application, do the following:
- Run `pnpm install` (or your package manager's install command) to install dependencies.
- Run `pnpm run dev` to start the [dev server](/guide/basic/server.md).
### Templates
When creating an application, choose from the following templates provided by `create-rsbuild`:
| Template | Official docs | Rsbuild integration guide |
| -------- | ------------------------------- | ------------------------------------------------------------- |
| vanilla | Native JavaScript | - |
| react | [React](https://react.dev/) | [Using React](/guide/framework/react.md) |
| vue | [Vue](https://vuejs.org/) | [Using Vue](/guide/framework/vue.md) |
| lit | [Lit](https://lit.dev/) | - |
| preact | [Preact](https://preactjs.com/) | [Using Preact](/guide/framework/preact.md) |
| svelte | [Svelte](https://svelte.dev/) | [Using Svelte](/guide/framework/svelte.md) |
| solid | [Solid](https://solidjs.com/) | [Using Solid](/guide/framework/solid.md) |
| octane | [Octane](https://octanejs.dev/) | [Using Octane](https://octanejs.dev/docs/build-tools#rsbuild) |
`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#starter) for community-maintained templates.
### Optional tools
`create-rsbuild` can help you set up the following commonly used tools. Use the arrow keys to navigate and the space bar to select. Press Enter without selecting anything to skip these tools.
| Tool | Use |
| ---------------------------------------------------------- | -------------------------------------------- |
| [Rstest](https://github.com/web-infra-dev/rstest) | Testing |
| [Rslint](https://github.com/web-infra-dev/rslint) | Linting |
| [ESLint](https://github.com/eslint/eslint) | Linting |
| [Prettier](https://github.com/prettier/prettier) | Formatting |
| [Biome](https://github.com/biomejs/biome) | Linting and formatting |
| [Storybook](https://storybook.js.org/) | Component development |
| [Tailwind CSS](https://tailwindcss.com) | Styling |
| [React Compiler](/guide/framework/react.md#react-compiler) | Optimizing React apps (React templates only) |
### 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 rslint,prettier
```
> See [Template examples](https://github.com/web-infra-dev/rsbuild/tree/main/packages/create-rsbuild#template-examples) for commands that create each template.
All CLI flags supported by `create-rsbuild`:
```text wrapCode
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
--no-git skip Git repository initialization
--tools add additional tools, comma separated
--skill add optional skills, comma separated
--override override files in target directory
--package-name specify the package name
--template-version specify the npm template version
Available templates: vanilla-js, vanilla-ts, react-js, react-ts, vue-js, vue-ts, lit-js, lit-ts, preact-js, preact-ts, svelte-js, svelte-ts, solid-js, solid-ts, solid2-js, solid2-ts, octane-js, octane-ts
Optional tools: react-compiler, rstest, eslint, rslint, biome, prettier, tailwindcss, storybook
Optional skills: rsbuild-best-practices, rstest-best-practices, vercel-react-best-practices
```
## Use Rsbuild in monorepos
The following monorepo tools provide Rsbuild integrations or examples for creating and managing Rsbuild applications in a workspace.
- [Nx](https://nx.dev/docs/technologies/build-tools/rsbuild/introduction) supports Rsbuild through the `@nx/rsbuild` plugin, including generators and executors for Nx workspaces.
- [Turborepo](https://turborepo.dev/docs/guides/frameworks/rsbuild) provides examples and guides for creating Rsbuild applications and using Rsbuild with Module Federation.
## Full-stack frameworks
If your application needs full-stack capabilities, you can directly use a full-stack framework built on Rsbuild, such as [TanStack Start](https://tanstack.com/start/latest) or [Modern.js](https://github.com/web-infra-dev/modern.js). These frameworks build on Rsbuild and add higher-level application features, such as SSR and routing.
- [React full-stack frameworks](/guide/framework/react.md#full-stack-frameworks)
- [Solid full-stack frameworks](/guide/framework/solid.md#full-stack-frameworks)
## Migrate from existing projects
To migrate from an existing project to Rsbuild, refer to the following guides:
- [Migrate from webpack](/guide/migration/webpack.md)
- [Migrate from Create React App](/guide/migration/cra.md)
- [Migrate from Vue CLI](/guide/migration/vue-cli.md)
- [Migrate from Vite](/guide/migration/vite.md)
- [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:
```sh [npm]
npm add @rsbuild/core -D
```
```sh [yarn]
yarn add @rsbuild/core -D
```
```sh [pnpm]
pnpm add @rsbuild/core -D
```
```sh [bun]
bun add @rsbuild/core -D
```
```sh [deno]
deno add npm:@rsbuild/core -D
```
After installation, use the following documents to configure your project:
- See [CLI](/guide/basic/cli.md) to learn about available CLI commands.
- See [Plugin list](/plugins/list/index.md) to select Rsbuild plugins.
- See [Configure Rsbuild](/guide/configuration/rsbuild.md) to configure Rsbuild.
## CLI
Rsbuild includes a lightweight CLI with commands like `dev` and `build`.
```json title="package.json"
{
"scripts": {
// start the dev server, equivalent to "rsbuild dev"
"dev": "rsbuild",
// build for production
"build": "rsbuild build",
// preview the production build locally
"preview": "rsbuild preview"
}
}
```
Refer to the [CLI](/guide/basic/cli.md) to learn about all available commands and options.
## Entry module
By default, Rsbuild CLI auto-detects `src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)` as the entry module. You can modify the entry module using the [source.entry](/config/source/entry.md) 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
[](https://npmjs.com/package/@rsbuild/core)
Core Rsbuild package that provides the CLI commands and JavaScript API.
### create-rsbuild
[](https://npmjs.com/package/create-rsbuild)
Create a new Rsbuild project.
## Next step
You may want:
[All features
Learn all features of Rsbuild
](/guide/start/features)[Config
Learn how to configure Rsbuild
](/guide/configuration/rsbuild)[Support Rsbuild
Support us with a star ⭐️
](https://github.com/web-infra-dev/rsbuild)
---
url: /guide/start/features.md
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Features
Overview of the main features supported by Rsbuild.
## JavaScript
| Features | Description | Links |
| -------------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Rspack | Use Rspack as the bundler 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.md)
|
| HMR | HMR is enabled by default in development mode |
[Hot module replacement](/guide/advanced/hmr.md)
[dev.hmr](/config/dev/hmr.md)
|
| Watch files | Optional feature, watch files and trigger page reloads or server restarts |
[dev.watchFiles](/config/dev/watch-files.md)
|
| SSR | Optional feature, implement server-side rendering |
[SSR](/guide/advanced/ssr.md)
|
| Proxy | Optional feature, proxy requests to the specified service |
[server.proxy](/config/server/proxy.md)
|
| Open page | Optional feature, automatically open page in browser when starting server |
[server.open](/config/server/open.md)
|
| 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
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# 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.md).
## 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.md) 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.md) 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.md) for more details.
## More
See additional glossary terms in [Rspack - Glossary](https://rspack.rs/misc/glossary).
---
url: /guide/start/ai.md
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# 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:
```sh [npx]
npx skills add rstackjs/agent-skills --skill migrate-to-rsbuild
```
```sh [yarn]
yarn dlx skills add rstackjs/agent-skills --skill migrate-to-rsbuild
```
```sh [pnpm]
pnpm dlx skills add rstackjs/agent-skills --skill migrate-to-rsbuild
```
```sh [bunx]
bunx skills add rstackjs/agent-skills --skill migrate-to-rsbuild
```
```sh [deno]
deno run -A npm:skills add rstackjs/agent-skills --skill migrate-to-rsbuild
```
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
## 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
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# 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.md#create-an-rsbuild-application). Run this command:
```sh [npm]
npm create rsbuild@latest
```
```sh [yarn]
yarn create rsbuild
```
```sh [pnpm]
pnpm create rsbuild@latest
```
```sh [bun]
bun create rsbuild@latest
```
Then select `React` when prompted to "Select framework".
## Full-stack frameworks
The following full-stack React frameworks are built on Rsbuild and reuse Rsbuild's plugin ecosystem.
### TanStack Start
[TanStack Start](https://tanstack.com/start/latest) is a full-stack React framework powered by TanStack Router. It provides full-document SSR, streaming, Server Functions, client/server builds, and more.
- [Documentation](https://tanstack.com/start/latest)
- [Basic example](https://github.com/rstackjs/rstack-examples/tree/main/rsbuild/tanstack-start)
- [RSC example](https://github.com/rstackjs/rstack-examples/tree/main/rsbuild/tanstack-start-rsc)
You can initialize the TanStack Start example project with:
```bash
npx giget gh:rstackjs/rstack-examples/rsbuild/tanstack-start tanstack-start
cd tanstack-start
pnpm i
```
To migrate a TanStack Start project from Vite, see [TanStack Start migration](/guide/migration/tanstack-start.md).
### Modern.js
[Modern.js](https://github.com/web-infra-dev/modern.js) is a progressive web framework built on Rsbuild that provides out-of-the-box full-stack development capabilities for React applications.
## Use React in an existing project
To compile React's JSX syntax, register the Rsbuild [React plugin](/plugins/list/plugin-react.md). 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.md).
:::
## 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.md).
## 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.
:::tip
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.
:::
Rsbuild supports two ways to enable React Compiler:
- Recommended: enable the Rust-based React Compiler through [@rsbuild/plugin-react](/plugins/list/plugin-react.md#reactcompiler). This provides a simpler setup and better build performance.
- Optional: use [React Compiler with @rsbuild/plugin-babel](/plugins/list/plugin-babel.md#use-react-compiler) if you are maintaining an existing Babel-based setup, using an older version of Rsbuild, or need Babel-plugin-based customization.
### How to use
If you are using Rsbuild 2.1.0+, you can enable the Rust-based React Compiler directly through `@rsbuild/plugin-react`:
```ts title="rsbuild.config.ts"
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
export default defineConfig({
plugins: [
pluginReact({
reactCompiler: true,
}),
],
});
```
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"
pluginReact({
reactCompiler: {
target: '18', // '17' | '18' | '19'
},
});
```
For more details, see [@rsbuild/plugin-react - reactCompiler](/plugins/list/plugin-react.md#reactcompiler).
## 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.md) 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.md#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.md#swcreactoptionsruntime).
### Via configuration
Configure through the `@rsbuild/plugin-react`'s [swcReactOptions](/plugins/list/plugin-react.md#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
;
};
```
## React Server Components
To use React Server Components (RSC) in a React application, you can use the [rsbuild-plugin-rsc](https://github.com/rstackjs/rsbuild-plugin-rsc) plugin.
Built on top of [Environments API](/guide/advanced/environments.md#environment-api), this plugin encapsulates the core capabilities required for RSC scenarios, allowing you to organize server and client components within the same application and simplify the integration and configuration process.
## 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
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Vue
This document explains how to build Vue applications with Rsbuild, including Vue 2 support.
## Create a Vue application
Create a Vue application with Rsbuild using [create-rsbuild](/guide/start/quick-start.md#create-an-rsbuild-application). Run this command:
```sh [npm]
npm create rsbuild@latest
```
```sh [yarn]
yarn create rsbuild
```
```sh [pnpm]
pnpm create rsbuild@latest
```
```sh [bun]
bun create rsbuild@latest
```
Then select `Vue` 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.md). 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.md).
:::
### 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.md).
:::
### 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;
}
```
## Vue DevTools
Vue DevTools is designed to enhance the Vue developer experience; it can significantly improve your productivity and debugging capabilities when working with Vue applications.
For Vue applications built with Rsbuild, use [vue-devtools-rstack](https://github.com/OskarLebuda/vue-devtools-rstack) to integrate Vue DevTools.
---
url: /guide/framework/preact.md
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Preact
Learn how to build a Preact application using Rsbuild.
## Create a Preact application
Create a Preact application with [create-rsbuild](/guide/start/quick-start.md#create-an-rsbuild-application):
```sh [npm]
npm create rsbuild@latest
```
```sh [yarn]
yarn create rsbuild
```
```sh [pnpm]
pnpm create rsbuild@latest
```
```sh [bun]
bun 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](/plugins/list/plugin-preact.md). The plugin will automatically add the necessary configuration for Preact builds.
For example, register the plugin in Rsbuild config:
```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
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Svelte
Learn how to build a Svelte application using Rsbuild.
## Create a Svelte application
Create a Svelte application with [create-rsbuild](/guide/start/quick-start.md#create-an-rsbuild-application):
```sh [npm]
npm create rsbuild@latest
```
```sh [yarn]
yarn create rsbuild
```
```sh [pnpm]
pnpm create rsbuild@latest
```
```sh [bun]
bun create rsbuild@latest
```
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.md). The plugin will automatically add the necessary configuration for Svelte builds.
For example, register the plugin in Rsbuild config:
```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
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# Solid
Learn how to build a Solid application using Rsbuild.
## Create a Solid application
Create a Solid application with [create-rsbuild](/guide/start/quick-start.md#create-an-rsbuild-application):
```sh [npm]
npm create rsbuild@latest
```
```sh [yarn]
yarn create rsbuild
```
```sh [pnpm]
pnpm create rsbuild@latest
```
```sh [bun]
bun create rsbuild@latest
```
Then select `Solid` when prompted to "Select framework".
## Full-stack frameworks
The following full-stack Solid frameworks are built on Rsbuild and reuse Rsbuild's plugin ecosystem.
### TanStack Start
[TanStack Start](https://tanstack.com/start/latest) is a full-stack framework powered by TanStack Router. It provides full-document SSR, streaming, Server Functions, client/server builds, and more.
- [Documentation](https://tanstack.com/start/latest)
- [Example project](https://github.com/rstackjs/rstack-examples/tree/main/rsbuild/tanstack-start-solid)
You can initialize the TanStack Start example project with:
```bash
npx giget gh:rstackjs/rstack-examples/rsbuild/tanstack-start-solid tanstack-start
cd tanstack-start
pnpm i
```
To migrate a TanStack Start project from Vite, see [TanStack Start migration](/guide/migration/tanstack-start.md).
## Use Solid in an existing project
To compile Solid components, you need to register the Rsbuild [Solid plugin](/plugins/list/plugin-solid.md). The plugin will automatically add the necessary configuration for Solid builds.
For example, register the plugin in Rsbuild config:
```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
---
> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
# CLI
Rsbuild includes a lightweight CLI with commands like [rsbuild dev](#rsbuild) 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.md) |
| `-c, --config ` | Set the configuration file (relative or absolute path), see [Specify config file](/guide/configuration/rsbuild.md#specify-config-file) |
| `--config-loader ` | Set the config file loader (`auto` \| `jiti` \| `native`), see [Specify config loader](/guide/configuration/rsbuild.md#specify-config-loader) |
| `--dist-path ` | Set the root directory of output files, see [output.distPath](/config/output/dist-path.md) |
| `--env-mode ` | Set the env mode to load the `.env.[mode]` file, see [Env mode](/guide/advanced/env-vars.md#env-mode) |
| `--env-dir ` | Set the directory for loading `.env` files, see [Env directory](/guide/advanced/env-vars.md#env-directory) |
| `--environment ` | Set the environment name(s) to build, see [Build specified environment](/guide/advanced/environments.md#build-a-specific-environment) |
| `-h, --help` | Display help for command |
| `--log-level ` | Set the log level (`info` \| `warn` \| `error` \| `silent`), see [logLevel](/config/log-level.md) |
| `-m, --mode ` | Set the build mode (`development` \| `production` \| `none`), see [mode](/config/mode.md) |
| `--no-env` | Disable loading of `.env` files |
| `--no-source-map` | Disable source maps, see [output.sourceMap](/config/output/source-map.md) |
| `-r, --root ` | Set the project root directory (absolute path or relative to [cwd](https://nodejs.org/api/process.html#processcwd)) |
| `--source-map` | Enable source maps, see [output.sourceMap](/config/output/source-map.md) |
For boolean flags, the `--no-` prefix can be used to explicitly disable the corresponding feature, such as `--no-env` or `--no-source-map`.
## rsbuild
The `rsbuild` command starts a local dev server and compiles source code for development. `rsbuild dev` is an alias for `rsbuild`.
```bash
Usage:
rsbuild [options]
rsbuild dev [options]
Options:
-o, --open [url] Open the page in browser on startup
--port Set the port number for the server
--strict-port Exit if the specified port is already in use
--host [host] Set the host that the server listens to
```
### Specifying host
By default, the dev server listens on `localhost`. Passing `--host` without a value will make the server listen on all network interfaces:
```bash
npx rsbuild --host
# equivalent to:
npx rsbuild --host 0.0.0.0
```
### Opening page
The `--open` option opens a page automatically when the dev server starts (equivalent to setting [server.open](/config/server/open.md) to `true`).
```bash
rsbuild --open
```
The `--open` option also accepts a specific URL to open. For example:
```bash
rsbuild --open http://localhost:3000/foo
```
The `--open` option can also be abbreviated to `-o`:
```bash
rsbuild -o
```
:::tip
When using both [server.open](/config/server/open.md) 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
--strict-port Exit if the specified port is already in use
--host [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