---
title: "Islands and islx"
description: "How Farm.js's islands mode renders server components on islx instead of React's Flight protocol, and how it runs libraries written for React Server Components."
canonical_url: "https://mcp.farmjs.dev/docs/server-rendering/islands"
markdown_url: "https://mcp.farmjs.dev/docs/server-rendering/islands.md"
last_updated: "2026-12-01"
x_farming_labs_generated_preamble: true
---

# Islands and islx
URL: /docs/server-rendering/islands
LLM index: /llms.txt
Description: How Farm.js's islands mode renders server components on islx instead of React's Flight protocol, and how it runs libraries written for React Server Components.

# Islands and islx

**Islands mode renders server components without React's Flight protocol.** Farm.js uses
[islx](https://github.com/farming-labs/islx) as its wire format end to end: the HTML a page
sends, the props and values its client components receive, its server actions, and its client
navigations. You write the same server and client components as for React Server Components.

```ts filename="farm.config.ts"
import { defineConfig } from "@farm.js/core";

export default defineConfig({
  serverComponents: { mode: "islands" },
  experimental: { serverActions: true },
});
```

## What replaces Flight

With `{ mode: "rsc" }`, the server renders a Flight payload (`react-server-dom-webpack`), and the
browser rebuilds the whole page from it. With `{ mode: "islands" }`, there is no Flight payload.
The page is ordinary server HTML, and islx marks the parts the browser hydrates.

|                                    | RSC (`mode: "rsc"`)                                                | Islands (`mode: "islands"`)                                                                            |
| ---------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| Server output                      | Flight payload, rendered to HTML                                   | HTML only, with islx markers                                                                           |
| What the browser hydrates          | the whole page, as one React root                                  | each client component, as its own root                                                                 |
| A client component's props         | inside the Flight payload                                          | `<script type="f/props">` after it                                                                     |
| Server output passed as `children` | inside the Flight payload                                          | kept as HTML in `<f-slot>`, or as a server tree when it holds client components                        |
| Large shared values                | inside the Flight payload                                          | sent once, keyed by content (`f/value`); a navigation leaves out values the browser holds (`F-Values`) |
| Server actions                     | Flight action references                                           | islx references, captured values sealed with AES-GCM                                                   |
| Client navigation                  | a Flight payload for the page                                      | the page's HTML, and only the layouts that changed (`F-Layouts`)                                       |
| Packages it needs                  | `react-server-dom-webpack`, `@vitejs/plugin-rsc` (pinned versions) | `@farm.js/islx` (a dependency of `@farm.js/core`)                                                      |

A client component's server HTML looks like this:

```html
<f-island src="/src/components/counter.tsx" export="Counter" props="_R_a_" strategy="load">
  <button>Count: 5</button>
</f-island>
<script type="f/props" for="_R_a_" ids="_R_ba_">
  {"start":5}
</script>
```

`strategy` is when the island hydrates (`load`, `idle`, `visible` or `interaction`), and `ids`
lets the browser give `useId` the ids in the HTML. The full contract is islx's
[SPEC.md](https://github.com/farming-labs/islx/blob/main/SPEC.md).

## How Farm.js uses islx

- **Server.** Farm.js renders the page once, on its normal server pipeline. Farm.js's compiler wraps
  every `"use client"` export in islx's island component, which writes the `<f-island>` element and
  its props. Server output passed to a client component renders once, inside it. Props take what
  RSC sends. Maps and sets can hold elements, and global symbols, errors (without their message),
  iterators, `Blob`s and `FormData` arrive as they left. Promises, `ReadableStream`s and async
  iterables stream in after the page, and elements they settle to render with their client
  components hydrated. A value that refers to itself arrives with the same cycle, through a
  promise or stream too. A plain function fails the render with an error that names the component
  and the prop.
- **MDX.** The client components an MDX file imports are islands too, whether a page imports the
  file or loads it with `import()`, as a content collection does. Farm.js reads the file's `import`
  and `export` blocks for them, not its frontmatter or its fenced code examples.
- **Tables, selects, SVG and lists.** A client component that renders a row, an option, a shape or
  a list item directly inside its parent makes that parent (the whole `<table>`, `<select>`,
  `<svg>` or `<ul>`) the island, since `<f-island>` cannot sit between them. The parent's server
  parts travel as a server tree and its client components hydrate in its root, so the HTML matches
  React Server Components'.
- **Browser.** Farm.js's client entry hands every `<f-island>` to islx's hydration runtime, which
  imports the island's module when its strategy is due and hydrates it in place. A page whose
  islands all wait loads a 2.4 KB boot script instead of the runtime. Once the page has loaded and
  the browser is idle, the boot script fetches the runtime's entry and the router without running
  them, so a first tap waits for its page alone (a connection that asks to save data skips this).
  When the page first needs the runtime, the boot script runs it and fetches what comes next with
  it: the router when a link starts it, and the modules of a layout that hydrates as one root when
  another interaction inside it does. They arrive in one round trip instead of one after another.
  A link clicked before the runtime runs has its page requested with the click, so the page and
  the runtime travel together and the router renders the response once it runs. A `Link` that
  prefetches has its page requested as soon as it is pressed, a tap's length before the click;
  any other link waits for the click, since its page may change something on the server. That first
  response carries every island value the page needs, including ones the current page already
  has. The next page renders before React DOM and islx arrive: they load beside it and hydrate its
  islands, which hold a click until then.
- **Layouts.** A layout that needs one React root (a client provider around the pages) renders as
  an islx server tree: the browser rebuilds it from the HTML, so its module stays on the server,
  and a navigation keeps the provider's state. The pages below it, Markdown pages included, join
  that tree, so every client component on them reads the provider, one that declares a deferred
  `island` strategy too: it hydrates with the layout instead of waiting. Until the layout hydrates,
  a navigation swaps the next page's HTML in, as for a page without one, and the layout keeps
  waiting for its strategy. Once it has hydrated, navigations render in its root.
- **Actions.** `"use server"` functions compile to islx action references. A form posts its action
  without a page load, or without JavaScript, and the page refreshes with its islands' state kept,
  including islands in Suspense content that streams in after the page.
  The browser sends action calls one at a time, in the order it receives them. A server query
  that calls a server function uses the same queue and refreshes the page when the call succeeds.
  A redirect returned by an action navigates to its destination instead.
  An action called from a client component can return elements, promises and streams, as under
  RSC: elements render on the server, and promises and streams settle in the browser after the
  call returns. Its arguments and result can refer to themselves, through a promise or stream in
  the result too. A value the server cannot carry (an element, a plain function, a class instance)
  can still be an argument: the action can only return it, and the browser gets the same object
  back. An action bound with `.bind` in the browser can be passed to another action, which RSC
  cannot do (React's browser client sends it as a temporary reference), and an action can return
  one that captured values.
- **Navigation.** A navigation fetches the page's HTML, streamed, with only the layouts the
  browser does not keep, and hydrates the islands it brings. A kept layout still runs on the
  server, so a guard in it (`redirect()`, `notFound()`, an auth check) decides the navigation.
  When a page request returns an HTTP redirect, the browser follows it with a full document
  navigation. This also handles redirect chains that end on another origin.
  The build skips that run for a layout that cannot decide a request: one whose modules, followed
  through every import, never throw, await, read `headers()`, `cookies()` or another
  per-request value, and import no package besides React and `Link`.

## How it compares with React Server Components

**Islands mode sends far less JavaScript on pages that do not hydrate at load, and costs about the
same or less everywhere else.** These are the numbers for one app built in both modes
(`benchmarks/server-components-payload`), each cell `"rsc"` then `"islands"`.

| Measure                    | Docs page       | Shop page       | Blog post       | Guide post      |
| -------------------------- | --------------- | --------------- | --------------- | --------------- |
| First-load JavaScript      | 71.0 to 27.6 KB | 71.0 to 27.6 KB | 71.0 to 27.6 KB | 71.0 to 27.6 KB |
| HTML document              | 16.3 to 16.2 KB | 5.5 to 5.9 KB   | 17.9 to 9.1 KB  | 18.0 to 9.5 KB  |
| Data per navigation        | 12.0 to 2.7 KB  | 3.8 to 4.4 KB   | 10.8 to 9.2 KB  | 10.9 to 9.6 KB  |
| First-load main thread     | 168 to 87 ms    | 162 to 80 ms    | 216 to 106 ms   | 216 to 105 ms   |
| First navigation           | 85 to 38 ms     | 87 to 47 ms     | 139 to 67 ms    | 134 to 77 ms    |
| First tap, 150 ms latency  | 199 to 102 ms   | 198 to 109 ms   | 232 to 137 ms   | 237 to 139 ms   |
| First tap, at 1.6 Mbit/s   | 265 to 119 ms   | 217 to 139 ms   | 281 to 180 ms   | 282 to 189 ms   |
| Navigation until painted   | 44 to 45 ms     | 43 to 44 ms     | 76 to 71 ms     | 73 to 77 ms     |
| Server requests per second | 246 to 256      | 564 to 701      | 31 to 224       | 52 to 176       |

A guide post is a blog post under a layout that hydrates as one root around a client theme
provider. Sizes are brotli at quality 5. Times are medians with Chrome at 4x CPU throttling; the
first navigation is the first click after a cold visit, with the pointer on the link for 100 ms,
over an emulated network that adds 50 ms to every response. The first tap is that click made as
an 80 ms tap, with 150 ms added to every response, with unlimited bandwidth or at 1.6 Mbit/s. Both
are served over HTTP/2 and compressed as a CDN would (`first-navigation.mjs`); navigation paint is
from a server on the same machine.
Requests per second are the median of 8 rounds alternating between the modes, on one Node process.
Measured 2026-11-20 on an Apple M1 with other work running (load average 11 to 20): times at
commit `33b402362` (Farm.js 0.1.77, islx 0.0.25), sizes, first navigations and first taps on
2026-11-22 (load average 7 to 71), once a layout that hydrates as one root kept waiting through a
navigation, and sizes again that day once a navigation named the island values the page holds
before islx loads. Sizes and first taps at 1.6 Mbit/s once more that day (load average 3 to 5),
once React loaded with React DOM, and the JavaScript of ten navigations once React DOM and islx
waited for an island that is due. First-load JavaScript and first taps at 1.6 Mbit/s again on
2026-11-23 (load average 3 to 4), once the boot script fetched the runtime's entry and router while
the page was idle, and first-load JavaScript and both first taps again that day (load average 4 to 5) once a `Link`'s page was requested on its press.

- **First load.** 2.4 KB of JavaScript runs instead of 71.0 KB, with about half the main-thread
  work, because these pages' client components wait for a click. Once the page is idle the boot
  script fetches the runtime's entry and router, 25.3 KB, without running them.
- **Navigation data.** A fifth of the data on docs pages, and slightly less on blog and guide
  posts. A navigation carries the page as islx HTML and leaves out the layouts and values the
  browser already holds. Under a layout that hydrates as one root, once the layout has hydrated, it
  carries only the page's server tree: half of RSC's data on shop pages.
- **Navigation on the server.** A docs navigation renders in 0.58 ms against 0.66 to 0.69 ms for
  RSC's `.rsc` request (medians of 1,495 interleaved requests, uncompressed), and sends 7.3 KB
  instead of 37.3 KB. The build skips the run of kept layouts that cannot decide a request.
- **Server.** 4% more requests per second on docs pages, 24% more on shop pages, 7.2 times more on
  a long blog post, where Flight serializes every token, and 3.4 times more on a guide post.
- **Navigation paint.** After the first navigation, within a millisecond of `"rsc"` on docs and shop
  pages, 5 ms sooner on blog posts and 4 ms later on guide posts.

Where islands mode does not win:

- **The runtime still has to arrive.** It is about 95 KB. The entry and router load on the first
  navigation or interaction, and React, React DOM and islx, three quarters of it, once a client
  component renders or hydrates: an island when its trigger fires, not a navigation to it. A visit
  that only navigates loads about 27 KB in ten pages, but a visitor who interacts has downloaded
  more JavaScript in total than with `"rsc"`. The savings are in what a visit pays before the page
  can be used.
- **A client component that hydrates at load** starts the runtime at once, so that page sends more
  JavaScript than `"rsc"`, not less: about 77 to 80 KB against 69.5 KB on a small app. The
  production build keeps navigation code in a separate 8 KB chunk, loaded on the first link hover,
  focus, tap, or navigation.
- **The first navigation pays for the runtime on a slow connection.** It loads the entry and the
  router that the first load left out, and the page renders before React DOM arrives. On a fast
  network a 100 ms hover loads them before the click, and with 150 ms of latency and unlimited
  bandwidth they travel with the page, so both are faster than `"rsc"`. At 1.6 Mbit/s the
  download decides: a first tap is 37 to 104 ms slower than with `"rsc"`, whose first load already
  brought its 71 KB. An instant tap (finger down and up at once) on a fast network (50 ms) is
  within a few ms of `"rsc"` on docs and blog pages, and 12 to 15 ms slower under a layout that
  hydrates as one root.
- **Until a layout that hydrates as one root does, its navigations carry more data.** The router
  swaps the next page's HTML in, so the layout keeps waiting, and the response carries that HTML as
  well as the page's server tree. That is 4.4 KB per navigation on shop pages against 3.8 KB with
  `"rsc"`, three quarters of it the page's HTML. React, React DOM and islx stay unloaded meanwhile,
  which saves more: 2.5 KB of JavaScript per navigation instead of 9.7, averaged over ten.
- **A small page's HTML is a little larger.** The shop page is 0.4 KB larger, for islx's island
  markers and props.

To measure it yourself, see the benchmark's
[README](https://github.com/farming-labs/farm.js/tree/main/benchmarks/server-components-payload).

## Libraries written for React Server Components

Islands mode runs libraries written for RSC the way their docs show it. Farm.js shims the RSC-only
parts:

| Pattern                                                                                                                                         | Works | How islands mode does it                                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A package that ships a `react-server` build (react-tweet's server `Tweet`, react-i18next, react-hook-form, swr, `@apollo/client/react`)         | yes   | A server module's import resolves to that build, and so do the packages it imports. Names it takes from a `"use client"` module stay client components. React itself keeps one build for server and client components. |
| `import "server-only"` in server code                                                                                                           | yes   | Server builds get an empty module. A browser build that imports it fails, naming the importer.                                                                                                                         |
| `import "client-only"`                                                                                                                          | yes   | A client component gets its empty build; a server component gets its `react-server` build, which throws, as RSC rejects it.                                                                                            |
| A package client component in a server component (`next-themes`, `sonner`'s `Toaster`, Radix parts, jotai's `Provider`, `SWRConfig`)            | yes   | Farm.js writes a client reference module for each export (`.farm/client-references/`) and server code imports that, so the export renders as an island, as RSC renders a client reference.                             |
| A workspace package's server component in a monorepo, rendering client components of its own dependencies                                       | yes   | Its server code is app code, as the bundler compiles it. A client reference resolves a package as the importer does, so a dependency the app does not have, or has at another version, still loads.                    |
| A server module that re-exports package client components (`export { Toaster } from "sonner"`)                                                  | yes   | The re-export points at the same client references, so modules that import it render those components as islands.                                                                                                      |
| Client components in workspace sources outside the app (a monorepo's `packages/ui/src`, through tsconfig `paths` or a relative import)          | yes   | They render as islands in `farm dev` and builds, like the app's own client components. The package needs no dependency on Farm.js.                                                                                     |
| A package provider around server content                                                                                                        | yes   | Client components inside it are its descendants and read its context.                                                                                                                                                  |
| A package provider in a layout                                                                                                                  | yes   | The layout renders as a server tree; the provider keeps its state across navigations.                                                                                                                                  |
| `useFormStatus` in a client component inside a server `<form>`                                                                                  | yes   | Farm.js points the import at islx's `useFormStatus`, which reports the server form's submit.                                                                                                                           |
| `useActionState` with a server action, in a form posted before JavaScript loads                                                                 | yes   | The page renders with the action's result, and its island hydrates with that state, as under React Server Components.                                                                                                  |
| `useId` in client components                                                                                                                    | yes   | Ids match the server HTML and are unique across islands.                                                                                                                                                               |
| `cache` from `react` in server code, or `React.cache`                                                                                           | yes   | Farm.js points them at a request-scoped `cache`, as RSC memoizes it, in app server code and in the `react-server` builds it reaches.                                                                                   |
| `cacheSignal()` from `react` in server code                                                                                                     | yes   | It returns the request's `AbortSignal`, which aborts when the response ends, as RSC's does after a render.                                                                                                             |
| A namespace import passed around as a value (`const { Close } = Dialog`)                                                                        | yes   | Its components become client references; its other exports (`createDialogScope`) come from the package.                                                                                                                |
| A package that mixes client components and server code in one entry (TanStack Query's `HydrationBoundary` beside `QueryClient` and `dehydrate`) | yes   | Only exports that come from a `"use client"` module become client references; the rest stay ordinary server imports, as in RSC.                                                                                        |
| Lowercase client components (`motion.div` from `motion/react-client`)                                                                           | yes   | They render as islands like any other client reference.                                                                                                                                                                |

A server module that imports a package reaching `client-only` without `"use client"` (React Aria
Components) fails with the import chain, in development and in the build, as RSC does. Import such
packages from a `"use client"` module.

Packages that Node cannot load as a bundler does, because their files import stylesheets
(react-tweet's CSS modules) or their ES module build is only a `module` field beside a CommonJS
`main` (react-wrap-balancer), are bundled into the server graph (`ssr.noExternal`) in every mode,
so development renders them as the production build does. In development, Farm.js also pre-bundles
the `module`-field packages that have no dependencies of their own with Vite's SSR dependency
optimizer, so a barrel package such as lucide-react loads as one module instead of one per icon.
The bundle is cached in `node_modules/.vite/deps_ssr` and rebuilt when the lockfile or config
changes.

`tests/e2e-server-components/compat.spec.ts` runs these against both engines, including TanStack
Query, Motion, react-tweet, react-hook-form, react-wrap-balancer, lucide-react, react-markdown,
recharts, React Aria Components and cmdk.

### Known differences

- **A module both server and client components import** is one module in islands mode, where RSC
  has a copy in each graph. Farm.js treats a module that any `"use client"` module reaches as client
  code, so its imports keep the packages' default builds, and a server component that uses it gets
  those too. Modules only server code imports get the `react-server` builds.
- **Package code that calls React's `cache`** outside a `react-server` build keeps React's own,
  which calls the function every time outside RSC.
- **`cacheSignal()` outside a request** (at module scope, in a build step) returns `null`. In RSC
  its signal aborts when the render finishes; in islands mode, when the response ends.
- **A namespace passed around as a value** carries the package's non-component exports
  (`createDialogScope`) as the real functions. RSC gives client references that throw when called.
- **Package client components always hydrate,** including ones that only render markup (icons),
  as RSC sends them as client components too. Each one is an island.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
