Quick Start
Online experience
Create a Farm Project
sh
npm create farm@latestsh
yarn create farm@latestsh
pnpm create farm@latestsh
bun create farm@latestsh
npm create farm farm-app --template reactsh
yarn create farm farm-app --template reactsh
pnpm create farm farm-app --template reactsh
bun create farm farm-app --template react| Template | Description | Optional Features |
|---|---|---|
| vanilla | Vanilla JavaScript | TypeScript |
| react | react18 | TypeScript |
| vue3 | vue3 | TypeScript |
| vue2 | vue2 | TypeScript |
| svelte | svelte | TypeScript |
| solid | solid | TypeScript |
| preact | preact | TypeScript |
| lit | lit | TypeScript |
| nestjs | nestjs | TypeScript |
| tauri | tauri2 | TypeScript |
| electron | electron | TypeScript |
2. Start the Project
Choose the package manager you like, install dependencies, then start the project. Then, start the project:
sh
cd farm-app && npm install && npm devsh
cd farm-app && yarn install && yarn devsh
cd farm-app && pnpm install && pnpm devsh
cd farm-app && bun install && bun devThe project will start at
http://localhost:9000by default.
3. Configuring the Project
The project is configured by farm.config.ts/js/mjs file in the root directory of the project.
farm.config.ts
import { defineConfig } from "@farmfe/core";
import react from '@farmfe/plugin-react';
export default defineConfig({
// Additional plugins
plugins: [react()],
});
4. Building the project
Build the Farm project as production-ready static files:
sh
npm run buildsh
yarn run buildsh
pnpm run buildsh
bun run buildThe built product is downgraded to ES2017 by default, and the product will be compressed and Tree Shake. If you want to preview the build product locally, you can execute npm run preview or npx farm preview.
4. Preview the build products
Start preview server
sh
npm run previewsh
yarn run previewsh
pnpm run previewsh
bun run preview
Farm