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.
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
Markdown
[](/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
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.
- <p align="center">
- <a href="https://farmjs.dev">
- <img src="./.github/assets/farmjs-lockup.svg" alt="Farm.js" width="420" />
- </a>
- </p>
- <p align="center">
- <strong>The framework for the web and agents.</strong>
- </p>
- <p align="center">
- 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.
- </p>
- <p align="center">
- <a href="https://farmjs.dev"><strong>Documentation</strong></a>
- Β·
- <a href="./examples"><strong>Examples</strong></a>
- Β·
- <a href="#-quick-start"><strong>Quick Start</strong></a>
- </p>
- <p align="center">
- <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>
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT license" /></a>
- <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue.svg" alt="TypeScript ready" /></a>
- </p>
- <p align="center">
- <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>
- </p>
- ## β¨ Built for Full-Stack Products
- | Feature | What it gives you |
- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
- | βοΈ **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). |
- | π **Server Actions** | Write mutations next to your components with `"use server"`, form actions, optional encrypted bound arguments, and configurable request security. |
- | β‘ **Blazingly fast development** | Vite-powered startup, on-demand transforms, and fast HMR keep the feedback loop nearly instant. |
- | π§ **Typed app-directory routing** | Pages, layouts, route groups, dynamic segments, loading states, error boundaries, middleware, and generated route types. |
- | π§© **Flexible rendering** | Choose streaming SSR, static generation, ISR, PPR, or deferred hydration islands route by route. |
- | π οΈ **Full-stack primitives** | Build with API routes, server functions, middleware, caching, KV storage, cron handlers, OpenAPI, and post-response work. |
- | π **First-party integrations** | Add authentication, billing, email, jobs, AI, API keys, databases, and provider-owned routes through one typed integration model. |
- | π **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. |
- | π§ͺ **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. |
- | π **Production-ready output** | Build deployable server and client output with Nitro-powered adapters and per-route runtime controls. |
- | π¨ **Great defaults** | Start with TypeScript, Tailwind CSS, sensible conventions, and a clean project structureβwithout assembling the framework yourself. |
- > **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.
- ## π Quick Start
- ### 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
- ```bash
- 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
- ```bash
- 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`:
- ```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`:
- ```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!** 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.
- Add a root layout in `src/app/layout.tsx`:
- ```tsx
- import type { LayoutProps } from "@farm.js/core";
- export default function RootLayout({ children }: LayoutProps) {
- return (
- <html>
- <body>{children}</body>
- </html>
- );
- }
- ```
- Start the development server:
- ```bash
- npx farm dev
- ```
- ## π Project Structure
- ```
- my-farm-app/
- βββ src/
- β βββ app/
- β βββ layout.tsx # Root layout
- β βββ page.tsx # Home page (/)
- β βββ about/
- β β βββ page.tsx # About page (/about)
- β βββ users/
- β βββ page.tsx # Users list (/users)
- β βββ [id]/
- β βββ page.tsx # User profile (/users/123)
- βββ farm.config.ts
- βββ package.json
- ```
- ## βοΈ Configuration
- Farm.js supports a powerful configuration system via `farm.config.ts`:
- ```typescript
- import { defineConfig } from "@farm.js/core";
- export default defineConfig({
- experimental: {
- serverComponents: true,
- },
- // Routing
- async redirects() {
- return [{ source: "/old", destination: "/new", permanent: true }];
- },
- // Custom headers
- async headers() {
- return [
- {
- source: "/:path*",
- headers: [{ key: "X-Frame-Options", value: "DENY" }],
- },
- ];
- },
- // Environment variables
- env: {
- API_URL: "https://api.example.com",
- },
- // Plugins
- plugins: [
- /* your plugins */
- ],
- // And much more...
- });
- ```
- See the [configuration docs](https://farmjs.dev/docs/configuration) for all options.
- ### Route-level Boundaries
- Farm.js supports Next.js-style route boundaries with special files inside a route segment:
- - `loading.tsx` - Route-level loading UI shown while the segment is suspended
- - `error.tsx` - Route-level error UI shown when the segment throws during render
- Example structure:
- ```text
- src/app/
- layout.tsx
- page.tsx
- loading.tsx
- error.tsx
- dashboard/
- page.tsx
- loading.tsx
- error.tsx
- ```
- Required config:
- ```ts
- import { defineConfig } from "@farm.js/core";
- export default defineConfig({
- experimental: {
- serverComponents: true,
- },
- });
- ```
- How it works:
- - `loading.tsx` is used automatically as the Suspense fallback for that segment
- - `error.tsx` is used automatically as the error boundary for that segment
- - You do not need to import or conditionally render `loading.tsx` in `page.tsx`
- - The route must actually suspend to show `loading.tsx` (for example: async server component, async layout, or a child wrapped by Suspense)
- - `loading.tsx` and `error.tsx` do not need `'use client'` unless they use client-only features like hooks or browser APIs
- Example:
- ```tsx
- // src/app/dashboard/loading.tsx
- export default function Loading() {
- return <p>Loading dashboard...</p>;
- }
- ```
- ```tsx
- // src/app/dashboard/page.tsx
- async function SlowContent() {
- await new Promise((resolve) => setTimeout(resolve, 2000));
- return <div>Dashboard ready</div>;
- }
- export default function DashboardPage() {
- return <SlowContent />;
- }
- ```
- ## π Plugin System
- Extend the framework with plugins: request hooks, HTML transforms, build and dev hooks, browser hooks, typed API routes, and their own database tables.
- ```typescript
- import { definePlugin } from "@farm.js/core";
- export const myPlugin = definePlugin({
- name: "acme:my-plugin",
- runtime: {
- before({ request }) {
- // Runs before Farm's route handler. Return a Response to answer early.
- },
- after({ response }) {
- // Return a new Response to change headers or the body.
- return response;
- },
- },
- render: {
- html(html) {
- // Rewrite a page's rendered HTML.
- return html;
- },
- },
- });
- ```
- 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.
- ## π― Core Concepts
- ### File-based Routing
- Farm.js uses Next.js App Router-style file-based routing:
- - `page.tsx` - Creates a route
- - `layout.tsx` - Shared UI for a route segment
- - `[param]/` - Dynamic route segment
- - `[...slug]/` - Catch-all route segment
- ### React Server Components
- Server Components run on the server and can directly access databases, file systems, or other server-only resources:
- ```tsx
- // This runs on the server
- export default async function BlogPost({ params }: { params: { slug: string } }) {
- const post = await getPostFromDatabase(params.slug);
- return (
- <article>
- <h1>{post.title}</h1>
- <p>{post.content}</p>
- </article>
- );
- }
- ```
- ### Client Components
- Use the `'use client'` directive for interactive components:
- ```tsx
- "use client";
- import { useState } from "react";
- export default function Counter() {
- const [count, setCount] = useState(0);
- return <button onClick={() => setCount(count + 1)}>Count: {count}</button>;
- }
- ```
- ## π Documentation
- Visit [farmjs.dev](https://farmjs.dev) for comprehensive documentation, guides, and API reference.
- ## ποΈ Development
- ### Prerequisites
- - Node.js 22.13 or newer
- - pnpm 8+
- ### Setup
- ```bash
- git clone https://github.com/farming-labs/farm.js.git
- cd farm.js
- ./scripts/setup.sh
- ```
- ### Development Commands
- ```bash
- # Install dependencies
- pnpm install
- # Build all packages
- pnpm build
- # Run tests (from root: runs tests in all packages; @farm.js/core runs Vitest)
- pnpm test
- # Run only @farm.js/core tests
- pnpm run test:farm
- # Run tests and save output to test-run.log
- pnpm run test:ci
- # then: cat test-run.log
- # Start playground
- cd playground && pnpm dev
- # Start documentation
- cd docs && pnpm dev
- # Run example
- cd examples/basic && pnpm dev
- ```
- ### Project Structure
- ```
- farm.js/
- βββ packages/
- β βββ farm/ # Core framework
- β βββ farm-cli/ # @farm.js/cli tools
- β βββ create-farm-app/ # App creation tool
- β βββ farm-react/ # React renderer + AOT compiler
- β βββ farm-{preact,solid,vue,svelte}/ # Other renderers
- βββ examples/
- β βββ basic/ # Basic example
- β βββ rsc-demo/ # Server components, actions, and queries
- β βββ stripe-integration/ # Typed integration usage
- βββ docs/ # Documentation (Farm.js)
- βββ playground/ # Development testing
- βββ tests/ # Integration tests
- ```
- ## π€ Contributing
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
- ### Quick Contribution Steps
- 1. Fork the repository
- 2. Create a feature branch: `git checkout -b feature/amazing-feature`
- 3. Make your changes and add tests
- 4. Push and create a Pull Request
- ## π Examples
- - **[Basic Example](./examples/basic)** - Routing, boundaries, middleware, storage, and rendering modes in one app
- - **[RSC Demo](./examples/rsc-demo)** - Server components, server actions, and server queries
- - **[React Compiler](./examples/react-compiler)** - The experimental AOT compiler side by side with baseline React
- - **[Stripe Integration](./examples/stripe-integration)** - Typed billing integration with provider-owned routes
- - **[Solid Renderer](./examples/solid-renderer)** - A Solid app on the same framework contracts
- - **[Preact Renderer](./examples/preact-renderer)** - A Preact app on the same framework contracts
- - **[Vue Renderer](./examples/vue-renderer)** - A Vue app on the same framework contracts
- - **[Svelte Renderer](./examples/svelte-renderer)** - A Svelte app on the same framework contracts
- ## π Ecosystem
- - **[Vite](https://vitejs.dev/)** - Build tool and development server
- - **[React](https://react.dev/)** - UI library with Server Components
- - **[TypeScript](https://www.typescriptlang.org/)** - Type safety and developer experience
- ## π License
- MIT Β© [Farming Labs](https://github.com/farming-labs)
- ## π Acknowledgments
- Farm.js is inspired by:
- - **[Next.js](https://nextjs.org/)** - For the excellent App Router API design
- - **[Vite](https://vitejs.dev/)** - For the incredible development experience
- - **[@lazarv/react-server](https://github.com/lazarv/react-server)** - For RSC implementation insights
- - **[Remix](https://remix.run/)** - For web-first development principles
- ---
- <div align="center">
- **[Documentation](https://farmjs.dev)** β’ **[Examples](./examples)** β’ **[Contributing](CONTRIBUTING.md)**
- Made with β€οΈ by <a href="https://www.farming-labs.dev"><img src="./.github/assets/farming-labs-mark.svg" alt="" height="18" align="center" /> Farming Labs</a> team
- </div>
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If itβs helped, pass it on.