Farm.js

Reference

A compact map of the main package exports and where to learn more.

Core exports

Export areaWhat it covers
@farm.js/coreConfig, app types, plugins, integrations, routing, OpenAPI, docs, cache.
@farm.js/core/clientLink, router helpers, callable route actions, API client, integration client.
@farm.js/core/plugin/clientAdvanced browser lifecycle manager and client plugin event types.
@farm.js/core/navigationNext-compatible redirect, notFound, and client navigation hooks.
@farm.js/core/headersNext-compatible request headers and cookies helpers.
@farm.js/core/routerLightweight route matching, href building, and active-route checks.
@farm.js/core/queryQuery and route param types.
@farm.js/core/storageKey/value clients, drivers, mounts, and getStorage().
@farm.js/core/cacheData cache, revalidation, cache keys.
@farm.js/cache-redisDistributed Redis cache, tag versions, and regeneration leases.
@farm.js/core/afterPost-response server work with after().
@farm.js/core/cronCron route authorization, schedule types, manifests, and deployment adapter helpers.
@farm.js/core/observabilityFarm events, request tracing, custom spans, and active trace context.
@farm.js/core/instrumentationStartup and shutdown convention types for development and production runtimes.
@farm.js/otelOptional Node OpenTelemetry SDK, OTLP exporter, and auto-instrumentation setup.
@farm.js/reactReact renderer descriptor and experimental AOT local-state compiler.
@farm.js/preactPreact renderer descriptor, streaming SSR, hydration, and Vite integration.
@farm.js/solidSolid renderer descriptor, SSR runtime, browser hydration, and Vite integration.
@farm.js/vueVue renderer descriptor, SFC compilation, SSR runtime, and browser hydration.
@farm.js/svelteSvelte renderer descriptor, component compilation, SSR, and browser hydration.
@farm.js/integrationsAuth, billing, email, jobs, AI, API keys, provider clients.
  1. Start with Getting Started and Project Structure.
  2. Choose a renderer, then read Routing, Layouts, and Rendering Model.
  3. Add API Routes, API Client, and Query.
  4. Choose integrations, KV storage, and database ownership once your product needs them.
  5. Finish with Deployment, Observability, and Reference.

Integration exports

PackageExports
@farm.js/coredefineIntegration, integrationRoute, defineIntegrationSchema, definePlugin, defineConfig.
@farm.js/core/theme/clientuseTheme, getTheme, setTheme, and toggleTheme for browser color-mode state.
@farm.js/core/theme/servergetTheme and getThemeSnapshot for cookie-backed server rendering.
@farm.js/core/croncronRoute, cron config types, schedule manifests, and deployment adapter helpers.
@farm.js/core/workflowsLegacy workflow-module APIs kept for compatibility. New schedules should use cron config and API routes.
@farm.js/core/clientuseAction, createIntegrations, createIntegrationClient, createIntegrationServerClient, endpoint.
@farm.js/core/plugin/clientcreateClientPluginManager and browser lifecycle types for advanced tooling.
@farm.js/core/navigationredirect, permanentRedirect, notFound, useRouter, usePathname, useSearchParams.
@farm.js/core/fontBuild-time localFont and remoteFont loaders with generated CSS, hashed assets, and preload hints.
@farm.js/core/headersheaders, cookies.
@farm.js/core/routercreateFarmRouter, matchFarmRoute, buildFarmRoutePath, isFarmRouteActive.
@farm.js/core/storagesqliteStorage, postgresStorage, redisStorage, createStorageClient, defineStorageClient.
@farm.js/cache-redisredisCache distributed cache adapter.
@farm.js/federationfederation build plugin for browser Module Federation producers and hosts.
@farm.js/federation/clientTyped loadRemote and preloadRemote browser helpers.
@farm.js/searchsearch build plugin and the headless createSearch browser client.
@farm.js/core/afterafter for short work that starts after the current response finishes.
@farm.js/stripe, @farm.js/polar, @farm.js/autumnDedicated billing integration packages.
@farm.js/auth0, @farm.js/authjs, @farm.js/better-auth, @farm.js/clerkDedicated auth integration packages.
@farm.js/supabase, @farm.js/workosDedicated auth integration packages with generated typed callers.
@farm.js/emailResend integration and email template helper.
@farm.js/jobsJobs integration, task, defineTasks, Trigger.dev runtime, Inngest runtime.
@farm.js/unkeyUnkey API key integration.
@farm.js/integrations/*Compatibility re-exports for older imports; new code should use the dedicated packages above.

Mental model

  • Pages and layouts are app UI.
  • API routes are app-owned HTTP handlers.
  • API clients are typed callers for app routes.
  • Integrations are provider or feature packages that can own routes, callers, schemas, providers, config, and lifecycle.
  • Plugins are framework-level hooks for server requests, rendering, builds, browser hydration, navigation, and runtime behavior.
  • KV storage uses getStorage() for values addressed by string keys.
  • Application models use an application-owned ORM; schema-backed integrations use ctx.args.db.
  • The current beta storage.client config name also accepts a raw integration database client, but that client is not a KV mount.
  • Cron maps a UTC schedule to an app-owned GET API route; it does not add durable workflow state.