Custom Framework Adapter

If your framework isn’t officially supported, you can build a custom adapter using the Servly adapter API.

Adapter Interface

import type { CIFComponent, AdapterConfig } from "@servly/sync-core";

interface FrameworkAdapter {
  name: string;
  generate(component: CIFComponent, config: AdapterConfig): GeneratedFile[];
  validate?(component: CIFComponent): ValidationResult;
}

Creating an Adapter

import { defineAdapter } from "@servly/sync-core";

export default defineAdapter({
  name: "my-framework",

  generate(component, config) {
    // Transform CIF to your framework's component format
    const code = renderTemplate(component);

    return [
      {
        path: `${component.name}.mf`,
        content: code,
      },
    ];
  },
});

Registering Your Adapter

In your servly.config.ts:

import { defineConfig } from "@servly/cli";
import myAdapter from "./my-adapter";

export default defineConfig({
  adapter: myAdapter,
  output: "./src/components/servly",
});