From d80584711ddc1b7617f6a18eefe13f5e96fa4bf1 Mon Sep 17 00:00:00 2001 From: Kinfe123 Date: Fri, 9 Oct 2026 10:00:54 -0700 Subject: [PATCH 1/2] Add a Farm.js framework guide --- docs.json | 1 + js/frameworks.mdx | 4 +++ js/frameworks/farmjs.mdx | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 js/frameworks/farmjs.mdx diff --git a/docs.json b/docs.json index 0a13cbe8c1..3d360181fb 100644 --- a/docs.json +++ b/docs.json @@ -511,6 +511,7 @@ "pages": [ "js/frameworks/astro", "js/frameworks/deno", + "js/frameworks/farmjs", "js/frameworks/meteor", "js/frameworks/nextjs", "js/frameworks/nuxtjs", diff --git a/js/frameworks.mdx b/js/frameworks.mdx index 49c5547076..42842139e1 100644 --- a/js/frameworks.mdx +++ b/js/frameworks.mdx @@ -9,6 +9,7 @@ Each one of the language guides will take you through creating and deploying a s * [Run an Astro App](/js/frameworks/astro/) * [Run a Deno App](/js/frameworks/deno/) +* [Run a Farm.js App](/js/frameworks/farmjs/) * [Run a Meteor App](/js/frameworks/meteor/) * [Run a Next.js App](/js/frameworks/nextjs/) * [Run a Nuxt App](/js/frameworks/nuxtjs/) @@ -24,6 +25,9 @@ Astro is the web framework for content-driven websites. ## Run a Deno App Deno is the open-source JavaScript runtime for the modern web. +## Run a Farm.js App +Farm.js is a full-stack framework with typed file routing, server actions, and streaming server rendering for React, Preact, Solid, Vue, and Svelte. + ## Run a Meteor App Meteor is a full-stack JavaScript framework for building modern web and mobile applications. diff --git a/js/frameworks/farmjs.mdx b/js/frameworks/farmjs.mdx new file mode 100644 index 0000000000..da7135eee9 --- /dev/null +++ b/js/frameworks/farmjs.mdx @@ -0,0 +1,68 @@ +--- +title: Run a Farm.js App +og:description: Farm.js is a full-stack framework with typed file routing, server actions, and streaming server rendering for React, Preact, Solid, Vue, and Svelte. +source_url: https://fly.io/docs/js/frameworks/farmjs/ +--- + +import FlyctlSnippet from '/snippets/js/frameworks/flyctl.mdx'; +import LaunchedSnippet from '/snippets/js/frameworks/launched.mdx'; + +Getting an application running on Fly.io is essentially working out how to package it as a deployable image. Once packaged it can be deployed to the Fly.io platform. + +In this guide we'll learn how to deploy a [Farm.js](https://farmjs.dev/) application on Fly.io. + +We'll be using the basic starter generated by `@farm.js/create-app`. It renders pages on the server and hydrates interactive components in the browser. + +## _Deploy a Farm.js app_ + +We'll assume you have Node.js 22.13 or later installed and can run `npm`. + + + +Now let's generate a new Farm.js app: + +```bash +npx @farm.js/create-app@latest my-farm-app +cd my-farm-app +``` + +`farm build` compiles the app into a self-contained Node.js server in `.farm/.output`. Add a `Dockerfile` to the root of the app that builds it and runs that server: + +```dockerfile +FROM node:22-slim AS build + +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . ./ +RUN npm run build + +FROM node:22-slim + +WORKDIR /app +COPY --from=build /app/.farm/.output ./.farm/.output + +ENV NODE_ENV=production +EXPOSE 3000 +CMD ["node", ".farm/.output/server/index.mjs"] +``` + +And a `.dockerignore` next to it: + +``` +node_modules +.farm +.git +``` + +The runtime image only copies `.farm/.output`, which already contains the server's dependencies. If you let `fly launch` generate a Dockerfile instead, it removes development dependencies before running `npm run start`, which removes the `farm` command that `start` calls. + +Now you're ready to deploy: + +```bash +fly launch +``` + +`fly launch` uses your `Dockerfile` and sets the internal port to `3000` from its `EXPOSE` line, which is the port the Farm.js server listens on. + + From 946bdba875cb4aa1638ae79ed326327329811d30 Mon Sep 17 00:00:00 2001 From: Kinfe123 Date: Fri, 9 Oct 2026 11:41:16 -0700 Subject: [PATCH 2/2] Explain which Farm.js start scripts survive the generated Dockerfile --- js/frameworks/farmjs.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/frameworks/farmjs.mdx b/js/frameworks/farmjs.mdx index da7135eee9..c53f097121 100644 --- a/js/frameworks/farmjs.mdx +++ b/js/frameworks/farmjs.mdx @@ -55,7 +55,7 @@ node_modules .git ``` -The runtime image only copies `.farm/.output`, which already contains the server's dependencies. If you let `fly launch` generate a Dockerfile instead, it removes development dependencies before running `npm run start`, which removes the `farm` command that `start` calls. +The runtime image only copies `.farm/.output`, which already contains the server's dependencies. If you let `fly launch` generate a Dockerfile instead, it removes development dependencies before running `npm run start`. That works when the `start` script is `node .farm/.output/server/index.mjs`, but not when it is `farm start`, because the `farm` command is a development dependency. Now you're ready to deploy: