Skip to main content

React

Create a React project based on Farm.

Farm provides two approaches to support creating React projects:

  • Use the create-farm scaffold to create a scaffold project
  • You can manually create a React project following the current documentation

Creating a React Project

npm
yarn
pnpm
bun

Select React template in Select Framework

Farm requires the registration of the @farmfe/plugin-react plugin to support React projects.

farm.config.ts

The @farmfe/plugin-react plugin is written in Rust, so you do not need to explicitly import it; you can register it by passing a string package name.

Integrating emotion

You can support emotion by registering the @swc/plugin-emotion plugin.

farm.config.ts
src/index.tsx

Integrating svgr

SVGR is a tool for transforming svgs into React components. Farm offers a Js plugin to support SVGR.

farm.config.ts

If you want to start DevServer

npm
yarn
pnpm
bun

If you need to run the build production environment product command

npm
yarn
pnpm
bun

If you need to preview your build product

npm
yarn
pnpm
bun

For more example details: React Example

Extremely Fast Web Build Tool Written in Rust

Copyright © 2024 Farm Community. Built with Docusaurus.