Skip to content
Back to search

farm.js

a full-stack, renderer-agnostic framework for the web and agents, with an experimental AOT React compiler.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/farming-labs/farm.js with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/farming-labs/farm.js'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/farming-labs--farm-js/badge.svg)](/listings/farming-labs--farm-js)

HTML

<a href="/listings/farming-labs--farm-js"><img src="/api/listings/farming-labs--farm-js/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Try It in Your Browser

No install needed: [open the playground on StackBlitz](https://stackblitz.com/github/farming-labs/farm.js/tree/main/examples/stackblitz?file=src%2Fapp%2Fpage.tsx&title=Farm.js%20Playground) to see server rendering, client islands, and typed server calls in one page.

Create a New App

pnpm create @farm.js/app my-app --template basic --typescript
cd my-app
pnpm dev

Your app will be running at `http://localhost:3000`!

Use `--list-templates` to choose a ready-to-configure Auth0, Auth.js, Autumn, Clerk, Inngest, Trigger.dev, Polar, Resend, Stripe, Supabase, Unkey, WorkOS, or AI starter.

Manual Installation

npm install @farm.js/core react react-dom
# or
pnpm add @farm.js/core react react-dom
# or
yarn add @farm.js/core react react-dom

Create a `farm.config.ts`:

import { defineConfig } from "@farm.js/core";

export default defineConfig({
  deploy: {
    target: "vercel",
  },
});

Farm uses `src` as the source directory by default. Add `srcDir` only when your app uses a different directory.

`defineFarmConfig` remains available as a deprecated exact alias of `defineConfig`.

Create your first page in `src/app/page.tsx`:

export default function HomePage() {
  return (
    <div className="min-h-screen bg-gray-50 flex items-center justify-center">
      <h1 className="text-5xl font-bold text-blue-600">Hello from Farm.js!</h1>
    </div>
  );
}

> πŸ’‘ **Tailwind CSS is pre-configured!** Just use Tailwind classes - no setup needed. See [TAILWIND_SETUP.md](./TAILWIND_SETUP.md) for details.

Add a root layout in `src/app/layout.tsx`:

import type { LayoutProps } from "@farm.js/core";

export default function RootLayout({ children }: LayoutProps) {
  return (
    <html>
      <body>{children}</body>
    </html>
  );
}

Start the development server:

npx farm dev

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md Β· README Β· 446 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <p align="center">
  2. <a href="https://farmjs.dev">
  3. <img src="./.github/assets/farmjs-lockup.svg" alt="Farm.js" width="420" />
  4. </a>
  5. </p>
  6. <p align="center">
  7. <strong>The framework for the web and agents.</strong>
  8. </p>
  9. <p align="center">
  10. Every Farm.js app serves its pages to people and to AI agents: server-rendered HTML, a Markdown copy of each page, and <code>llms.txt</code>, on by default. Turn on MCP and your server functions become tools agents can call. Bring any agent runtime: <a href="https://farmjs.dev/docs/integrations/eve">Eve</a> and <a href="https://farmjs.dev/docs/integrations/cf-agent">Cloudflare Agents</a> plug in through Farm's open <a href="https://farmjs.dev/docs/integrations#agent-runtimes">agent runtime contract</a>, and the <a href="https://farmjs.dev/docs/integrations/agent-frameworks">AI SDK, Mastra, LangGraph, and the OpenAI Agents SDK</a> run in a plain API route. Built on Vite and Nitro, with typed routes, Server Actions, and streaming SSR. React is the default renderer, and beta Preact, Solid, Vue, and Svelte adapters use the same routing and server contracts. See <a href="https://farmjs.dev/docs/stability">Stability and Support</a> for what 0.1 covers.
  11. </p>
  12. <p align="center">
  13. <a href="https://farmjs.dev"><strong>Documentation</strong></a>
  14. Β·
  15. <a href="./examples"><strong>Examples</strong></a>
  16. Β·
  17. <a href="#-quick-start"><strong>Quick Start</strong></a>
  18. </p>
  19. <p align="center">
  20. <a href="https://www.npmjs.com/package/@farm.js/core"><img src="https://img.shields.io/npm/v/%40farm.js%2Fcore?label=%40farm.js%2Fcore&color=black" alt="npm version" /></a>
  21. <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT license" /></a>
  22. <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue.svg" alt="TypeScript ready" /></a>
  23. </p>
  24. <p align="center">
  25. <a href="https://stackblitz.com/github/farming-labs/farm.js/tree/main/examples/stackblitz?file=src%2Fapp%2Fpage.tsx&title=Farm.js%20Playground"><img src="https://developer.stackblitz.com/img/open_in_stackblitz.svg" alt="Open in StackBlitz" /></a>
  26. </p>
  27. ## ✨ Built for Full-Stack Products
  28. | Feature | What it gives you |
  29. | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  30. | βš›οΈ **Custom RSC renderer** | A purpose-built RSC, streaming SSR, and client hydration pipeline, with optional Rust-native rendering for eligible host-only regions through [Strata](https://github.com/farming-labs/strata). |
  31. | πŸ”„ **Server Actions** | Write mutations next to your components with `"use server"`, form actions, optional encrypted bound arguments, and configurable request security. |
  32. | ⚑ **Blazingly fast development** | Vite-powered startup, on-demand transforms, and fast HMR keep the feedback loop nearly instant. |
  33. | 🧭 **Typed app-directory routing** | Pages, layouts, route groups, dynamic segments, loading states, error boundaries, middleware, and generated route types. |
  34. | 🧩 **Flexible rendering** | Choose streaming SSR, static generation, ISR, PPR, or deferred hydration islands route by route. |
  35. | πŸ› οΈ **Full-stack primitives** | Build with API routes, server functions, middleware, caching, KV storage, cron handlers, OpenAPI, and post-response work. |
  36. | πŸ”Œ **First-party integrations** | Add authentication, billing, email, jobs, AI, API keys, databases, and provider-owned routes through one typed integration model. |
  37. | 🎭 **Renderer choice** | React by default, with Preact, Solid, Vue, and Svelte renderers selected by one line of config β€” same routes, server functions, and integrations everywhere. |
  38. | πŸ§ͺ **AOT React compiler** | An experimental compiler turns eligible components into direct DOM updates that skip reconciliation, falling back to normal React whenever eligibility can't be proven. |
  39. | πŸš€ **Production-ready output** | Build deployable server and client output with Nitro-powered adapters and per-route runtime controls. |
  40. | 🎨 **Great defaults** | Start with TypeScript, Tailwind CSS, sensible conventions, and a clean project structureβ€”without assembling the framework yourself. |
  41. > **Experimental native rendering:** Farm.js can automatically send eligible, server-only React subtrees through the [Strata](https://github.com/farming-labs/strata) native renderer while safely falling back to normal React rendering for unsupported trees.
  42. ## πŸš€ Quick Start
  43. ### Try It in Your Browser
  44. No install needed: [open the playground on StackBlitz](https://stackblitz.com/github/farming-labs/farm.js/tree/main/examples/stackblitz?file=src%2Fapp%2Fpage.tsx&title=Farm.js%20Playground) to see server rendering, client islands, and typed server calls in one page.
  45. ### Create a New App
  46. ```bash
  47. pnpm create @farm.js/app my-app --template basic --typescript
  48. cd my-app
  49. pnpm dev
  50. ```
  51. Your app will be running at `http://localhost:3000`!
  52. Use `--list-templates` to choose a ready-to-configure Auth0, Auth.js, Autumn, Clerk, Inngest,
  53. Trigger.dev, Polar, Resend, Stripe, Supabase, Unkey, WorkOS, or AI starter.
  54. ### Manual Installation
  55. ```bash
  56. npm install @farm.js/core react react-dom
  57. # or
  58. pnpm add @farm.js/core react react-dom
  59. # or
  60. yarn add @farm.js/core react react-dom
  61. ```
  62. Create a `farm.config.ts`:
  63. ```ts
  64. import { defineConfig } from "@farm.js/core";
  65. export default defineConfig({
  66. deploy: {
  67. target: "vercel",
  68. },
  69. });
  70. ```
  71. Farm uses `src` as the source directory by default. Add `srcDir` only when your app uses a
  72. different directory.
  73. `defineFarmConfig` remains available as a deprecated exact alias of `defineConfig`.
  74. Create your first page in `src/app/page.tsx`:
  75. ```tsx
  76. export default function HomePage() {
  77. return (
  78. <div className="min-h-screen bg-gray-50 flex items-center justify-center">
  79. <h1 className="text-5xl font-bold text-blue-600">Hello from Farm.js!</h1>
  80. </div>
  81. );
  82. }
  83. ```
  84. > πŸ’‘ **Tailwind CSS is pre-configured!** Apps from `create-app` include it, so just use Tailwind classes. In an existing app, install `tailwindcss` and `@tailwindcss/vite` and add `@import "tailwindcss";` to your stylesheet; Farm loads the Vite plugin for you.
  85. Add a root layout in `src/app/layout.tsx`:
  86. ```tsx
  87. import type { LayoutProps } from "@farm.js/core";
  88. export default function RootLayout({ children }: LayoutProps) {
  89. return (
  90. <html>
  91. <body>{children}</body>
  92. </html>
  93. );
  94. }
  95. ```
  96. Start the development server:
  97. ```bash
  98. npx farm dev
  99. ```
  100. ## πŸ“ Project Structure
  101. ```
  102. my-farm-app/
  103. β”œβ”€β”€ src/
  104. β”‚ └── app/
  105. β”‚ β”œβ”€β”€ layout.tsx # Root layout
  106. β”‚ β”œβ”€β”€ page.tsx # Home page (/)
  107. β”‚ β”œβ”€β”€ about/
  108. β”‚ β”‚ └── page.tsx # About page (/about)
  109. β”‚ └── users/
  110. β”‚ β”œβ”€β”€ page.tsx # Users list (/users)
  111. β”‚ └── [id]/
  112. β”‚ └── page.tsx # User profile (/users/123)
  113. β”œβ”€β”€ farm.config.ts
  114. └── package.json
  115. ```
  116. ## βš™οΈ Configuration
  117. Farm.js supports a powerful configuration system via `farm.config.ts`:
  118. ```typescript
  119. import { defineConfig } from "@farm.js/core";
  120. export default defineConfig({
  121. experimental: {
  122. serverComponents: true,
  123. },
  124. // Routing
  125. async redirects() {
  126. return [{ source: "/old", destination: "/new", permanent: true }];
  127. },
  128. // Custom headers
  129. async headers() {
  130. return [
  131. {
  132. source: "/:path*",
  133. headers: [{ key: "X-Frame-Options", value: "DENY" }],
  134. },
  135. ];
  136. },
  137. // Environment variables
  138. env: {
  139. API_URL: "https://api.example.com",
  140. },
  141. // Plugins
  142. plugins: [
  143. /* your plugins */
  144. ],
  145. // And much more...
  146. });
  147. ```
  148. See the [configuration docs](https://farmjs.dev/docs/configuration) for all options.
  149. ### Route-level Boundaries
  150. Farm.js supports Next.js-style route boundaries with special files inside a route segment:
  151. - `loading.tsx` - Route-level loading UI shown while the segment is suspended
  152. - `error.tsx` - Route-level error UI shown when the segment throws during render
  153. Example structure:
  154. ```text
  155. src/app/
  156. layout.tsx
  157. page.tsx
  158. loading.tsx
  159. error.tsx
  160. dashboard/
  161. page.tsx
  162. loading.tsx
  163. error.tsx
  164. ```
  165. Required config:
  166. ```ts
  167. import { defineConfig } from "@farm.js/core";
  168. export default defineConfig({
  169. experimental: {
  170. serverComponents: true,
  171. },
  172. });
  173. ```
  174. How it works:
  175. - `loading.tsx` is used automatically as the Suspense fallback for that segment
  176. - `error.tsx` is used automatically as the error boundary for that segment
  177. - You do not need to import or conditionally render `loading.tsx` in `page.tsx`
  178. - The route must actually suspend to show `loading.tsx` (for example: async server component, async layout, or a child wrapped by Suspense)
  179. - `loading.tsx` and `error.tsx` do not need `'use client'` unless they use client-only features like hooks or browser APIs
  180. Example:
  181. ```tsx
  182. // src/app/dashboard/loading.tsx
  183. export default function Loading() {
  184. return <p>Loading dashboard...</p>;
  185. }
  186. ```
  187. ```tsx
  188. // src/app/dashboard/page.tsx
  189. async function SlowContent() {
  190. await new Promise((resolve) => setTimeout(resolve, 2000));
  191. return <div>Dashboard ready</div>;
  192. }
  193. export default function DashboardPage() {
  194. return <SlowContent />;
  195. }
  196. ```
  197. ## πŸ”Œ Plugin System
  198. Extend the framework with plugins: request hooks, HTML transforms, build and dev hooks, browser hooks, typed API routes, and their own database tables.
  199. ```typescript
  200. import { definePlugin } from "@farm.js/core";
  201. export const myPlugin = definePlugin({
  202. name: "acme:my-plugin",
  203. runtime: {
  204. before({ request }) {
  205. // Runs before Farm's route handler. Return a Response to answer early.
  206. },
  207. after({ response }) {
  208. // Return a new Response to change headers or the body.
  209. return response;
  210. },
  211. },
  212. render: {
  213. html(html) {
  214. // Rewrite a page's rendered HTML.
  215. return html;
  216. },
  217. },
  218. });
  219. ```
  220. See the [Plugin System guide](./PLUGIN_SYSTEM.md) for every plugin option and hook, and [Create a Plugin](https://farmjs.dev/docs/plugins/create-plugin) for walkthroughs.
  221. ## 🎯 Core Concepts
  222. ### File-based Routing
  223. Farm.js uses Next.js App Router-style file-based routing:
  224. - `page.tsx` - Creates a route
  225. - `layout.tsx` - Shared UI for a route segment
  226. - `[param]/` - Dynamic route segment
  227. - `[...slug]/` - Catch-all route segment
  228. ### React Server Components
  229. Server Components run on the server and can directly access databases, file systems, or other server-only resources:
  230. ```tsx
  231. // This runs on the server
  232. export default async function BlogPost({ params }: { params: { slug: string } }) {
  233. const post = await getPostFromDatabase(params.slug);
  234. return (
  235. <article>
  236. <h1>{post.title}</h1>
  237. <p>{post.content}</p>
  238. </article>
  239. );
  240. }
  241. ```
  242. ### Client Components
  243. Use the `'use client'` directive for interactive components:
  244. ```tsx
  245. "use client";
  246. import { useState } from "react";
  247. export default function Counter() {
  248. const [count, setCount] = useState(0);
  249. return <button onClick={() => setCount(count + 1)}>Count: {count}</button>;
  250. }
  251. ```
  252. ## πŸ“š Documentation
  253. Visit [farmjs.dev](https://farmjs.dev) for comprehensive documentation, guides, and API reference.
  254. ## πŸ—οΈ Development
  255. ### Prerequisites
  256. - Node.js 22.13 or newer
  257. - pnpm 8+
  258. ### Setup
  259. ```bash
  260. git clone https://github.com/farming-labs/farm.js.git
  261. cd farm.js
  262. ./scripts/setup.sh
  263. ```
  264. ### Development Commands
  265. ```bash
  266. # Install dependencies
  267. pnpm install
  268. # Build all packages
  269. pnpm build
  270. # Run tests (from root: runs tests in all packages; @farm.js/core runs Vitest)
  271. pnpm test
  272. # Run only @farm.js/core tests
  273. pnpm run test:farm
  274. # Run tests and save output to test-run.log
  275. pnpm run test:ci
  276. # then: cat test-run.log
  277. # Start playground
  278. cd playground && pnpm dev
  279. # Start documentation
  280. cd docs && pnpm dev
  281. # Run example
  282. cd examples/basic && pnpm dev
  283. ```
  284. ### Project Structure
  285. ```
  286. farm.js/
  287. β”œβ”€β”€ packages/
  288. β”‚ β”œβ”€β”€ farm/ # Core framework
  289. β”‚ β”œβ”€β”€ farm-cli/ # @farm.js/cli tools
  290. β”‚ β”œβ”€β”€ create-farm-app/ # App creation tool
  291. β”‚ β”œβ”€β”€ farm-react/ # React renderer + AOT compiler
  292. β”‚ └── farm-{preact,solid,vue,svelte}/ # Other renderers
  293. β”œβ”€β”€ examples/
  294. β”‚ β”œβ”€β”€ basic/ # Basic example
  295. β”‚ β”œβ”€β”€ rsc-demo/ # Server components, actions, and queries
  296. β”‚ └── stripe-integration/ # Typed integration usage
  297. β”œβ”€β”€ docs/ # Documentation (Farm.js)
  298. β”œβ”€β”€ playground/ # Development testing
  299. └── tests/ # Integration tests
  300. ```
  301. ## 🀝 Contributing
  302. We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
  303. ### Quick Contribution Steps
  304. 1. Fork the repository
  305. 2. Create a feature branch: `git checkout -b feature/amazing-feature`
  306. 3. Make your changes and add tests
  307. 4. Push and create a Pull Request
  308. ## 🌟 Examples
  309. - **[Basic Example](./examples/basic)** - Routing, boundaries, middleware, storage, and rendering modes in one app
  310. - **[RSC Demo](./examples/rsc-demo)** - Server components, server actions, and server queries
  311. - **[React Compiler](./examples/react-compiler)** - The experimental AOT compiler side by side with baseline React
  312. - **[Stripe Integration](./examples/stripe-integration)** - Typed billing integration with provider-owned routes
  313. - **[Solid Renderer](./examples/solid-renderer)** - A Solid app on the same framework contracts
  314. - **[Preact Renderer](./examples/preact-renderer)** - A Preact app on the same framework contracts
  315. - **[Vue Renderer](./examples/vue-renderer)** - A Vue app on the same framework contracts
  316. - **[Svelte Renderer](./examples/svelte-renderer)** - A Svelte app on the same framework contracts
  317. ## πŸ”— Ecosystem
  318. - **[Vite](https://vitejs.dev/)** - Build tool and development server
  319. - **[React](https://react.dev/)** - UI library with Server Components
  320. - **[TypeScript](https://www.typescriptlang.org/)** - Type safety and developer experience
  321. ## πŸ“„ License
  322. MIT Β© [Farming Labs](https://github.com/farming-labs)
  323. ## πŸ™ Acknowledgments
  324. Farm.js is inspired by:
  325. - **[Next.js](https://nextjs.org/)** - For the excellent App Router API design
  326. - **[Vite](https://vitejs.dev/)** - For the incredible development experience
  327. - **[@lazarv/react-server](https://github.com/lazarv/react-server)** - For RSC implementation insights
  328. - **[Remix](https://remix.run/)** - For web-first development principles
  329. ---
  330. <div align="center">
  331. **[Documentation](https://farmjs.dev)** β€’ **[Examples](./examples)** β€’ **[Contributing](CONTRIBUTING.md)**
  332. Made with ❀️ by&ensp;<a href="https://www.farming-labs.dev"><img src="./.github/assets/farming-labs-mark.svg" alt="" height="18" align="center" />&nbsp;Farming Labs</a> team
  333. </div>

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.