feat: add pluggable Solid renderer

Merged
KI
4mo ago
+3664-656

Summary

  • introduce a renderer contract while preserving React as the zero-config default
  • add the @farm.js/solid adapter for Solid SSR, client hydration, JSX compilation, and navigation
  • make route rendering, client boundaries, manifests, Nitro output, and built-in UI renderer-aware
  • add --renderer solid scaffolding for the basic CLI starter
  • add renderer configuration documentation and compatibility coverage
  • add a runnable Solid example with a colocated, validated FARMJS server function and typed endpoint transport

Why

FARMJS currently assumes React throughout its rendering pipeline. This change separates framework-owned server features from UI-library-specific rendering so applications can select Solid without changing routing, layouts, API routes, middleware, observability, theme configuration, or deployment behavior.

React remains the default, so existing projects do not need configuration changes.

Developer experience

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

export default defineConfig({
  renderer: solid(),
});

A Solid starter can be created with:

pnpm create @farm.js/app@beta my-solid-app --template basic --renderer solid --typescript

The example under examples/solid-renderer demonstrates Solid SSR and hydration together with a colocated createServerFn. The browser uses the generated typed API client, and the endpoint invokes the validated server function without shipping its handler to the browser.

Compatibility

  • React remains the implicit renderer
  • existing React route and client-boundary behavior is covered by regression tests
  • integration starters continue to target React until their UI packages are migrated
  • the automatic direct server-function transform remains React/RSC-specific; Solid uses the renderer-neutral typed endpoint transport in this change

Validation

  • React renderer regression suite: 32 tests passed
  • create-app suite: 9 tests passed
  • @farm.js/solid: 3 tests passed
  • core and Solid builds/type checks passed
  • Solid example type generation and type check passed
  • browser E2E verified SSR, hydration, typed POST, server execution, and signal update with no console errors
  • production Node build served both the page and POST /api/greeting successfully
  • git diff --check passed

Summary by cubic

Introduced a pluggable renderer contract and added Solid support via @farm.js/solid, enabling Solid SSR, hydration, and JSX without changing Farm’s routing or server features. React stays the default; apps can opt-in to Solid with renderer: solid().

  • New Features

    • Added renderer descriptor API (@farm.js/core/renderer) with React default and Solid option.
    • Published @farm.js/solid for SSR, hydration, JSX compilation, and vite integration.
    • Made route rendering, manifests, Nitro output, and built-in UI renderer-aware.
    • Implemented manifest-driven render plans (HTML fragment navigation and hydration strategy).
    • Updated client router to consume render plans and commit HTML fragments.
    • Added --renderer solid to create-farm-app, Solid starter templates, and a runnable example.
    • Updated docs with renderer selection and Solid setup.
  • Refactors

    • Separated framework-owned server features from UI-library rendering and hydration.
    • Introduced renderer-specific server/client modules and Vite plugin loading.
    • Extended route and layout manifests with hydration flags and island strategies.
    • Moved default Not Found styles to a shared module and kept React compatibility as-is.